Documentation ¶
Index ¶
- func AbortWithError(gCtx *gin.Context, code int, err error)
- func AbortWithErrorAndStacktrace(gCtx *gin.Context, code int, err error)
- func AssertFirstGinError(t *testing.T, ginCtx *gin.Context, expectedStatusCode int, ...)
- func AssertPreparedResponseStatusCode(t *testing.T, ginCtx *gin.Context, expectedStatusCode int)
- func AssertRequestResponse(t *testing.T, rec *httptest.ResponseRecorder, expectedStatusCode int, ...)
- func ErrorHandlingMiddleware(gCtx *gin.Context)
- func NewErrorEntry(httpStatus int, details string, appendStackTrace bool) error
- func PanicCatchingMiddleware(gCtx *gin.Context)
- type ErrorMessage
- type ErrorResponse
- type ErrorResponseAssertion
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AbortWithError ¶
AbortWithError aborts the current request.
func AbortWithErrorAndStacktrace ¶
AbortWithErrorAndStacktrace aborts the current request; it attaches an stack trace to the error; it will be printed into the logs but not as response.
func AssertFirstGinError ¶
func AssertFirstGinError(t *testing.T, ginCtx *gin.Context, expectedStatusCode int, expectedErrorMessage string)
AssertFirstGinError checks the enlisted errors within gin.Context. The assertion looks for the first error; it shall be an error submitted by AbortWithError ro AbortWithErrorAndStacktrace
func AssertPreparedResponseStatusCode ¶
AssertPreparedResponseStatusCode checks the current gin.Context to not have a committed HTTP status code within the respconse It searches the enlisted errors for an prepared status code which will be picked up by ErrorHandlingMiddleware
func AssertRequestResponse ¶
func AssertRequestResponse(t *testing.T, rec *httptest.ResponseRecorder, expectedStatusCode int, errors ...ErrorResponseAssertion)
AssertRequestResponse checks the recorded response for a httptest.ResponseRecorder
func ErrorHandlingMiddleware ¶
ErrorHandlingMiddleware takes the last registered Error and creates a response based on this error
func NewErrorEntry ¶
func PanicCatchingMiddleware ¶
Types ¶
type ErrorMessage ¶
type ErrorMessage struct { //A unique error id Id string `json:"id"` //The HTTP status which can result from this error Status string `json:"status"` //A message containing a detailed description Detail string `json:"detail"` }
ErrorMessage is a representation of an error based on https://jsonapi.org/format/#errors
type ErrorResponse ¶
type ErrorResponse []ErrorMessage