Documentation
¶
Index ¶
- func HandleError(err error, c echo.Context)
- func LogMiddleware(logger *logging.ZapEventLogger) echo.MiddlewareFunc
- type ContextualError
- type PDPError
- func (e *PDPError) Error() string
- func (e *PDPError) LogContext() map[string]interface{}
- func (e *PDPError) OriginalError() error
- func (e *PDPError) PublicMessage() string
- func (e *PDPError) StatusCode() int
- func (e *PDPError) WithContext(key string, value interface{}) *PDPError
- func (e *PDPError) WithPublicMessage(message string) *PDPError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandleError ¶
HandleError converts any error to an HTTP response It's especially helpful for handling our custom ContextualError
func LogMiddleware ¶
func LogMiddleware(logger *logging.ZapEventLogger) echo.MiddlewareFunc
LogMiddleware returns a middleware that logs requests using the IPFS go-log logger
Types ¶
type ContextualError ¶
type ContextualError interface {
error
// StatusCode returns the HTTP status code that should be returned to the client
StatusCode() int
// LogContext returns a map of additional context for logging
LogContext() map[string]interface{}
// PublicMessage returns a message safe to return to the client
PublicMessage() string
// OriginalError returns the underlying error, if any
OriginalError() error
}
ContextualError is a richer error interface that provides additional context about an error that occurred during request handling.
type PDPError ¶
type PDPError struct {
Operation string // The operation that failed (e.g., "ProofSetAddRoot")
Message string // Internal error message (for logs)
ClientMessage string // Message safe to return to clients
Code int // HTTP status code
Err error // Original error, if any
Context map[string]interface{} // Additional context for logging
}
PDPError implements the ContextualError interface
func (*PDPError) LogContext ¶
LogContext returns context information for logging
func (*PDPError) OriginalError ¶
OriginalError returns the underlying error
func (*PDPError) PublicMessage ¶
PublicMessage returns a message safe for client consumption
func (*PDPError) StatusCode ¶
StatusCode returns the HTTP status code
func (*PDPError) WithContext ¶
WithContext adds context information to the error
func (*PDPError) WithPublicMessage ¶
WithPublicMessage sets a client-safe message