webapp
Some checks failed
Docker Build and Publish / publish (push) Failing after 1m33s

This commit is contained in:
Eugene Howe
2026-02-17 09:47:30 -05:00
parent af09672ee3
commit b0957bfa49
102 changed files with 4213 additions and 378 deletions

43
internal/utils/error.go Normal file
View File

@@ -0,0 +1,43 @@
package utils
import (
"net/http"
"github.com/swaggest/rest"
)
// CustomApplicationError is a marker interface that tells error middleware to serialize this error as-is, using Json schema.
type CustomApplicationError interface {
rest.ErrWithHTTPStatus
CustomApplicationError()
}
type ApplicationError struct {
Message string `json:"message"`
code int
}
var (
_ CustomApplicationError = ApplicationError{}
)
func NewApplicationError(message string, code int) ApplicationError {
return ApplicationError{
Message: message,
code: code,
}
}
func (e ApplicationError) Error() string {
return e.Message
}
func (e ApplicationError) HTTPStatus() int {
return e.code
}
func (e ApplicationError) CustomApplicationError() {}
func ValidationError(message string) ApplicationError {
return NewApplicationError(message, http.StatusUnprocessableEntity)
}