package aerr import ( "fmt" ) // NewBadRequest will generate an HTTP Error 400. func NewBadRequest() *Error { return &Error{ Code: 400, httpCode: 400, Msg: "Bad Request", } } // NewBadRequestf will generate an HTTP Error 400 with a custom message. func NewBadRequestf(format string, a ...any) *Error { aErr := NewBadRequest() return aErr.SetMessage(fmt.Sprintf(format, a...)) } // NewUnauthorized will generate an HTTP Error 401. func NewUnauthorized() *Error { return &Error{ Code: 401, httpCode: 401, Msg: "Unauthorized", } } // NewUnauthorizedf will generate an HTTP Error 401 with a custom message. func NewUnauthorizedf(format string, a ...any) *Error { aErr := NewUnauthorized() return aErr.SetMessage(fmt.Sprintf(format, a...)) } // NewPaymentRequired will generate an HTTP Error 402. func NewPaymentRequired() *Error { return &Error{ Code: 402, httpCode: 402, Msg: "Payment Required", } } // NewPaymentRequiredf will generate an HTTP Error 402 with a custom message. func NewPaymentRequiredf(format string, a ...any) *Error { aErr := NewPaymentRequired() return aErr.SetMessage(fmt.Sprintf(format, a...)) } // NewForbidden will generate an HTTP Error 403. func NewForbidden() *Error { return &Error{ Code: 403, httpCode: 403, Msg: "Forbidden", } } // NewForbiddenf will generate an HTTP Error 403 with a custom message. func NewForbiddenf(format string, a ...any) *Error { aErr := NewForbidden() return aErr.SetMessage(fmt.Sprintf(format, a...)) } // NewNotFound will generate an HTTP Error 404. func NewNotFound() *Error { return &Error{ Code: 404, httpCode: 404, Msg: "Not Found", } } // NewNotFoundf will generate an HTTP Error 404 with a custom message. func NewNotFoundf(format string, a ...any) *Error { aErr := NewNotFound() return aErr.SetMessage(fmt.Sprintf(format, a...)) } // NewMethodNotAllowed will generate an HTTP Error 405. func NewMethodNotAllowed() *Error { return &Error{ Code: 405, httpCode: 405, Msg: "Method Not Allowed", } } // NewMethodNotAllowedf will generate an HTTP Error 405 with a custom message. func NewMethodNotAllowedf(format string, a ...any) *Error { aErr := NewMethodNotAllowed() return aErr.SetMessage(fmt.Sprintf(format, a...)) } // NewNotAcceptable will generate an HTTP Error 406. func NewNotAcceptable() *Error { return &Error{ Code: 406, httpCode: 406, Msg: "Not Acceptable", } } // NewNotAcceptablef will generate an HTTP Error 406 with a custom message. func NewNotAcceptablef(format string, a ...any) *Error { aErr := NewNotAcceptable() return aErr.SetMessage(fmt.Sprintf(format, a...)) } // NewProxyAuthenticationRequired will generate an HTTP Error 407. func NewProxyAuthenticationRequired() *Error { return &Error{ Code: 407, httpCode: 407, Msg: "Proxy Authentication Required", } } // NewProxyAuthenticationRequiredf will generate an HTTP Error 407 with a custom message. func NewProxyAuthenticationRequiredf(format string, a ...any) *Error { aErr := NewProxyAuthenticationRequired() return aErr.SetMessage(fmt.Sprintf(format, a...)) } // NewRequestTimeout will generate an HTTP Error 408. func NewRequestTimeout() *Error { return &Error{ Code: 408, httpCode: 408, Msg: "Request Timeout", } } // NewRequestTimeoutf will generate an HTTP Error 408 with a custom message. func NewRequestTimeoutf(format string, a ...any) *Error { aErr := NewRequestTimeout() return aErr.SetMessage(fmt.Sprintf(format, a...)) } // NewConflict will generate an HTTP Error 409. func NewConflict() *Error { return &Error{ Code: 409, httpCode: 409, Msg: "Conflict", } } // NewConflictf will generate an HTTP Error 409 with a custom message. func NewConflictf(format string, a ...any) *Error { aErr := NewConflict() return aErr.SetMessage(fmt.Sprintf(format, a...)) } // NewGone will generate an HTTP Error 410. func NewGone() *Error { return &Error{ Code: 410, httpCode: 410, Msg: "Gone", } } // NewGonef will generate an HTTP Error 410 with a custom message. func NewGonef(format string, a ...any) *Error { aErr := NewGone() return aErr.SetMessage(fmt.Sprintf(format, a...)) } // NewLengthRequired will generate an HTTP Error 411. func NewLengthRequired() *Error { return &Error{ Code: 411, httpCode: 411, Msg: "Length Required", } } // NewLengthRequiredf will generate an HTTP Error 411 with a custom message. func NewLengthRequiredf(format string, a ...any) *Error { aErr := NewLengthRequired() return aErr.SetMessage(fmt.Sprintf(format, a...)) } // NewPreconditionFailed will generate an HTTP Error 412. func NewPreconditionFailed() *Error { return &Error{ Code: 412, httpCode: 412, Msg: "Precondition Failed", } } // NewPreconditionFailedf will generate an HTTP Error 412 with a custom message. func NewPreconditionFailedf(format string, a ...any) *Error { aErr := NewPreconditionFailed() return aErr.SetMessage(fmt.Sprintf(format, a...)) } // NewPayloadTooLarge will generate an HTTP Error 413. func NewPayloadTooLarge() *Error { return &Error{ Code: 413, httpCode: 413, Msg: "Payload Too Large", } } // NewPayloadTooLargef will generate an HTTP Error 413 with a custom message. func NewPayloadTooLargef(format string, a ...any) *Error { aErr := NewPayloadTooLarge() return aErr.SetMessage(fmt.Sprintf(format, a...)) } // NewURITooLong will generate an HTTP Error 414. func NewURITooLong() *Error { return &Error{ Code: 414, httpCode: 414, Msg: "URI Too Long", } } // NewURITooLongf will generate an HTTP Error 414 with a custom message. func NewURITooLongf(format string, a ...any) *Error { aErr := NewURITooLong() return aErr.SetMessage(fmt.Sprintf(format, a...)) } // NewUnsupportedMediaType will generate an HTTP Error 415. func NewUnsupportedMediaType() *Error { return &Error{ Code: 415, httpCode: 415, Msg: "Unsupported Media Type", } } // NewUnsupportedMediaTypef will generate an HTTP Error 415 with a custom message. func NewUnsupportedMediaTypef(format string, a ...any) *Error { aErr := NewUnsupportedMediaType() return aErr.SetMessage(fmt.Sprintf(format, a...)) } // NewRangeNotSatisfiable will generate an HTTP Error 416. func NewRangeNotSatisfiable() *Error { return &Error{ Code: 416, httpCode: 416, Msg: "Range Not Satisfiable", } } // NewRangeNotSatisfiablef will generate an HTTP Error 416 with a custom message. func NewRangeNotSatisfiablef(format string, a ...any) *Error { aErr := NewRangeNotSatisfiable() return aErr.SetMessage(fmt.Sprintf(format, a...)) } // NewExpectationFailed will generate an HTTP Error 417. func NewExpectationFailed() *Error { return &Error{ Code: 417, httpCode: 417, Msg: "Expectation Failed", } } // NewExpectationFailedf will generate an HTTP Error 417 with a custom message. func NewExpectationFailedf(format string, a ...any) *Error { aErr := NewExpectationFailed() return aErr.SetMessage(fmt.Sprintf(format, a...)) } // NewMisdirectedRequest will generate an HTTP Error 421. func NewMisdirectedRequest() *Error { return &Error{ Code: 421, httpCode: 421, Msg: "Misdirected Request", } } // NewMisdirectedRequestf will generate an HTTP Error 421 with a custom message. func NewMisdirectedRequestf(format string, a ...any) *Error { aErr := NewMisdirectedRequest() return aErr.SetMessage(fmt.Sprintf(format, a...)) } // NewUnprocessableEntity will generate an HTTP Error 422. func NewUnprocessableEntity() *Error { return &Error{ Code: 422, httpCode: 422, Msg: "Unprocessable Entity", } } // NewUnprocessableEntityf will generate an HTTP Error 422 with a custom message. func NewUnprocessableEntityf(format string, a ...any) *Error { aErr := NewUnprocessableEntity() return aErr.SetMessage(fmt.Sprintf(format, a...)) } // NewLocked will generate an HTTP Error 423. func NewLocked() *Error { return &Error{ Code: 423, httpCode: 423, Msg: "Locked", } } // NewLockedf will generate an HTTP Error 423 with a custom message. func NewLockedf(format string, a ...any) *Error { aErr := NewLocked() return aErr.SetMessage(fmt.Sprintf(format, a...)) } // NewFailedDependency will generate an HTTP Error 424. func NewFailedDependency() *Error { return &Error{ Code: 424, httpCode: 424, Msg: "Failed Dependency", } } // NewFailedDependencyf will generate an HTTP Error 424 with a custom message. func NewFailedDependencyf(format string, a ...any) *Error { aErr := NewFailedDependency() return aErr.SetMessage(fmt.Sprintf(format, a...)) } // NewTooEarly will generate an HTTP Error 425. func NewTooEarly() *Error { return &Error{ Code: 425, httpCode: 425, Msg: "Too Early", } } // NewTooEarlyf will generate an HTTP Error 425 with a custom message. func NewTooEarlyf(format string, a ...any) *Error { aErr := NewTooEarly() return aErr.SetMessage(fmt.Sprintf(format, a...)) } // NewUpgradeRequired will generate an HTTP Error 426. func NewUpgradeRequired() *Error { return &Error{ Code: 426, httpCode: 426, Msg: "Upgrade Required", } } // NewUpgradeRequiredf will generate an HTTP Error 426 with a custom message. func NewUpgradeRequiredf(format string, a ...any) *Error { aErr := NewUpgradeRequired() return aErr.SetMessage(fmt.Sprintf(format, a...)) } // NewPreconditionRequired will generate an HTTP Error 428. func NewPreconditionRequired() *Error { return &Error{ Code: 428, httpCode: 428, Msg: "Precondition Required", } } // NewPreconditionRequiredf will generate an HTTP Error 428 with a custom message. func NewPreconditionRequiredf(format string, a ...any) *Error { aErr := NewPreconditionRequired() return aErr.SetMessage(fmt.Sprintf(format, a...)) } // NewTooManyRequests will generate an HTTP Error 429. func NewTooManyRequests() *Error { return &Error{ Code: 429, httpCode: 429, Msg: "Too Many Requests", } } // NewTooManyRequestsf will generate an HTTP Error 429 with a custom message. func NewTooManyRequestsf(format string, a ...any) *Error { aErr := NewTooManyRequests() return aErr.SetMessage(fmt.Sprintf(format, a...)) } // NewRequestHeaderFieldsTooLarge will generate an HTTP Error 431. func NewRequestHeaderFieldsTooLarge() *Error { return &Error{ Code: 431, httpCode: 431, Msg: "Request Header Fields Too Large", } } // NewRequestHeaderFieldsTooLargef will generate an HTTP Error 431 with a custom message. func NewRequestHeaderFieldsTooLargef(format string, a ...any) *Error { aErr := NewRequestHeaderFieldsTooLarge() return aErr.SetMessage(fmt.Sprintf(format, a...)) } // NewUnavailableForLegalReasons will generate an HTTP Error 451. func NewUnavailableForLegalReasons() *Error { return &Error{ Code: 451, httpCode: 451, Msg: "Unavailable For Legal Reasons", } } // NewUnavailableForLegalReasonsf will generate an HTTP Error 451 with a custom message. func NewUnavailableForLegalReasonsf(format string, a ...any) *Error { aErr := NewUnavailableForLegalReasons() return aErr.SetMessage(fmt.Sprintf(format, a...)) }