156 lines
4.0 KiB
Go
156 lines
4.0 KiB
Go
package aerr
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
// NewInternalServerError will generate an HTTP Error 500.
|
|
func NewInternalServerError() *Error {
|
|
return &Error{
|
|
Code: 500,
|
|
httpCode: 500,
|
|
Msg: "Internal Server Error",
|
|
}
|
|
}
|
|
|
|
// NewInternalServerErrorf will generate an HTTP Error 500 with a custom message.
|
|
func NewInternalServerErrorf(format string, a ...any) *Error {
|
|
aErr := NewInternalServerError()
|
|
return aErr.SetMessage(fmt.Sprintf(format, a...))
|
|
}
|
|
|
|
// NewNotImplemented will generate an HTTP Error 501.
|
|
func NewNotImplemented() *Error {
|
|
return &Error{
|
|
Code: 501,
|
|
httpCode: 501,
|
|
Msg: "Not Implemented",
|
|
}
|
|
}
|
|
|
|
// NewNotImplementedf will generate an HTTP Error 501 with a custom message.
|
|
func NewNotImplementedf(format string, a ...any) *Error {
|
|
aErr := NewNotImplemented()
|
|
return aErr.SetMessage(fmt.Sprintf(format, a...))
|
|
}
|
|
|
|
// NewBadGateway will generate an HTTP Error 502.
|
|
func NewBadGateway() *Error {
|
|
return &Error{
|
|
Code: 502,
|
|
httpCode: 502,
|
|
Msg: "Bad Gateway",
|
|
}
|
|
}
|
|
|
|
// NewBadGatewayf will generate an HTTP Error 502 with a custom message.
|
|
func NewBadGatewayf(format string, a ...any) *Error {
|
|
aErr := NewBadGateway()
|
|
return aErr.SetMessage(fmt.Sprintf(format, a...))
|
|
}
|
|
|
|
// NewServiceUnavailable will generate an HTTP Error 503.
|
|
func NewServiceUnavailable() *Error {
|
|
return &Error{
|
|
Code: 503,
|
|
httpCode: 503,
|
|
Msg: "Service Unavailable",
|
|
}
|
|
}
|
|
|
|
// NewServiceUnavailablef will generate an HTTP Error 503 with a custom message.
|
|
func NewServiceUnavailablef(format string, a ...any) *Error {
|
|
aErr := NewServiceUnavailable()
|
|
return aErr.SetMessage(fmt.Sprintf(format, a...))
|
|
}
|
|
|
|
// NewGatewayTimeout will generate an HTTP Error 504.
|
|
func NewGatewayTimeout() *Error {
|
|
return &Error{
|
|
Code: 504,
|
|
httpCode: 504,
|
|
Msg: "Gateway Timeout",
|
|
}
|
|
}
|
|
|
|
// NewGatewayTimeoutf will generate an HTTP Error 504 with a custom message.
|
|
func NewGatewayTimeoutf(format string, a ...any) *Error {
|
|
aErr := NewGatewayTimeout()
|
|
return aErr.SetMessage(fmt.Sprintf(format, a...))
|
|
}
|
|
|
|
// NewHTTPVersionNotSupported will generate an HTTP Error 505.
|
|
func NewHTTPVersionNotSupported() *Error {
|
|
return &Error{
|
|
Code: 505,
|
|
httpCode: 505,
|
|
Msg: "HTTP Version Not Supported",
|
|
}
|
|
}
|
|
|
|
// NewHTTPVersionNotSupportedf will generate an HTTP Error 505 with a custom message.
|
|
func NewHTTPVersionNotSupportedf(format string, a ...any) *Error {
|
|
aErr := NewHTTPVersionNotSupported()
|
|
return aErr.SetMessage(fmt.Sprintf(format, a...))
|
|
}
|
|
|
|
// NewVariantAlsoNegotiates will generate an HTTP Error 506.
|
|
func NewVariantAlsoNegotiates() *Error {
|
|
return &Error{
|
|
Code: 506,
|
|
httpCode: 506,
|
|
Msg: "Variant Also Negotiates",
|
|
}
|
|
}
|
|
|
|
// NewVariantAlsoNegotiatesf will generate an HTTP Error 506 with a custom message.
|
|
func NewVariantAlsoNegotiatesf(format string, a ...any) *Error {
|
|
aErr := NewVariantAlsoNegotiates()
|
|
return aErr.SetMessage(fmt.Sprintf(format, a...))
|
|
}
|
|
|
|
// NewInsufficientStorage will generate an HTTP Error 507.
|
|
func NewInsufficientStorage() *Error {
|
|
return &Error{
|
|
Code: 507,
|
|
httpCode: 507,
|
|
Msg: "Insufficient Storage",
|
|
}
|
|
}
|
|
|
|
// NewInsufficientStoragef will generate an HTTP Error 507 with a custom message.
|
|
func NewInsufficientStoragef(format string, a ...any) *Error {
|
|
aErr := NewInsufficientStorage()
|
|
return aErr.SetMessage(fmt.Sprintf(format, a...))
|
|
}
|
|
|
|
// NewLoopDetected will generate an HTTP Error 508.
|
|
func NewLoopDetected() *Error {
|
|
return &Error{
|
|
Code: 508,
|
|
httpCode: 508,
|
|
Msg: "Loop Detected",
|
|
}
|
|
}
|
|
|
|
// NewLoopDetectedf will generate an HTTP Error 508 with a custom message.
|
|
func NewLoopDetectedf(format string, a ...any) *Error {
|
|
aErr := NewLoopDetected()
|
|
return aErr.SetMessage(fmt.Sprintf(format, a...))
|
|
}
|
|
|
|
// NewNotExtended will generate an HTTP Error 510.
|
|
func NewNotExtended() *Error {
|
|
return &Error{
|
|
Code: 510,
|
|
httpCode: 510,
|
|
Msg: "Not Extended",
|
|
}
|
|
}
|
|
|
|
// NewNotExtendedf will generate an HTTP Error 510 with a custom message.
|
|
func NewNotExtendedf(format string, a ...any) *Error {
|
|
aErr := NewNotExtended()
|
|
return aErr.SetMessage(fmt.Sprintf(format, a...))
|
|
}
|