Documentation
¶
Overview ¶
Package workflowhttp maps the errors of vogel/workflow to HTTP status codes and the error codes of vogel/httpx/response. It is a separate package so the workflow engine itself stays free of any HTTP dependency.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Status ¶
Status returns the HTTP status and response code for err when it wraps a workflow sentinel a client can cause (checked with errors.Is), and ok = false otherwise. A caller writes the mapped response when ok is true, and logs err and answers 500 when it is false:
if status, code, ok := workflowhttp.Status(err); ok {
response.Error(w, r, status, code, err.Error())
return
}
The mapping is:
- 404 NOT_FOUND: ErrCaseNotFound, ErrTokenNotFound.
- 409 CONFLICT: ErrConflict, ErrAlreadyAssigned, ErrCaseClosed, ErrInvalidTransition, ErrReturnNotVisited, ErrNoRoute, ErrGuardRejected, ErrLastBranch, ErrJoinRejected, ErrAlreadyExpired, ErrNotOverdue, ErrCaseExists, ErrNotAssigned.
- 422 UNPROCESSABLE_ENTITY: ErrCommentRequired, ErrCommentNotAllowed, ErrReasonRequired, ErrTokenRequired, ErrInvalidActor.
- 400 VALIDATION_ERROR: ErrOffsetOutOfRange.
Every other error, ErrInvalidDefinition, ErrUnknownEffect and ErrTooManyDecisionHops included, is not mapped.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.