github.com/GeniusesGroup/libgo@v0.0.0-20220929090155-5ff932cb408e/protocol/error.go (about) 1 /* For license and copyright information please see the LEGAL file in the code repository */ 2 3 package protocol 4 5 // Errors is the interface that must implement by any Application. 6 type Errors interface { 7 RegisterError(err Error) 8 GetErrorByID(id MediaTypeID) (err Error) 9 GetErrorByMediaType(mt string) (err Error) 10 } 11 12 // Error is similar to opaque error model describe here: https://dave.cheney.net/paste/gocon-spring-2016.pdf 13 // or this RFC: https://tools.ietf.org/html/rfc7807 14 type Error interface { 15 // Init() must call protocol.App.RegisterError() to register the error in application 16 // Init(mediatype string) 17 18 // Check both flat or chain situation. 19 Equal(Error) bool 20 21 // Who cause the error? 22 // Internal : means calling process logic has runtime bugs like HTTP server error status codes ( 500 – 599 ). 23 // Caller : Opposite of internal that indicate caller give some data that cause the error like HTTP client error status codes ( 400 – 499 ) 24 Internal() bool 25 Temporary() bool // opposite is permanent situation 26 27 // Notify error to user by graphic, sound and vibration (Haptic Feedback) 28 Notify() 29 30 // Add below method is not force by this interface but we must implement it to respect golang error interface as inner syntax 31 // **ATTENTION** assign Error in error typed variables cause serious problems. 32 // **ATTENTION** nil interface assign into other interface don't make nil value. 33 Error() string 34 35 MediaType 36 Stringer 37 }