MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / NewAPIError

Function NewAPIError

internal/apierror/apierror.go:55–62  ·  view source on GitHub ↗

NewAPIError creates a new APIError instance. It logs the error details and returns the error object with the provided code, message, and additional details.

(code ErrorCode, message string, details interface{})

Source from the content-addressed store, hash-verified

53// NewAPIError creates a new APIError instance.
54// It logs the error details and returns the error object with the provided code, message, and additional details.
55func NewAPIError(code ErrorCode, message string, details interface{}) APIError {
56 logrus.WithField("details", details).Error("API error") // Log the error details for monitoring and debugging.
57 return APIError{
58 Code: code,
59 Message: message,
60 Details: details,
61 }
62}
63
64// MapErrorToHTTPStatus maps APIError codes to appropriate HTTP status codes.
65// It returns the corresponding HTTP status code for the given APIError.

Callers 15

CreateIdentityMethod · 0.92
GetIdentityByIDMethod · 0.92
GetAllIdentitiesMethod · 0.92
UpdateIdentityMethod · 0.92
DeleteIdentityMethod · 0.92
CreateLedgerMethod · 0.92
GetAllLedgersMethod · 0.92
GetLedgerByIDMethod · 0.92

Calls 1

ErrorMethod · 0.45

Tested by 2

TestNewAPIErrorFunction · 0.74
TestMapErrorToHTTPStatusFunction · 0.74