github.com/geniusesgroup/libgo@v0.0.0-20220713101832-828057a9d3d4/protocol/error.go (about)

     1  /* For license and copyright information please see LEGAL file in 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 uint64) (err Error)
     9  	GetErrorByMediaType(mt string) (err Error)
    10  }
    11  
    12  // New() function in any package must call Application.RegisterError() to save the error in application
    13  // It is similar to opaque error model describe here: https://dave.cheney.net/paste/gocon-spring-2016.pdf
    14  // or this RFC: https://tools.ietf.org/html/rfc7807
    15  type Error interface {
    16  	// Check both flat or chain situation.
    17  	Equal(Error) bool
    18  
    19  	// Who cause the error?
    20  	// Internal	: means calling process logic has runtime bugs like HTTP server error status codes ( 500 – 599 ).
    21  	// Caller	: Opposite of internal that indicate caller give some data that cause the error like HTTP client error status codes ( 400 – 499 )
    22  	Internal() bool
    23  	Temporary() bool // opposite is permanent situation
    24  
    25  	// Notify error to user by graphic, sound and vibration (Haptic Feedback)
    26  	Notify()
    27  
    28  	MediaType
    29  	Stringer
    30  }