Annotated Java methods can throw any of the following:
- Standard HTTP response beans:
- {@link oaj.http.response.BadRequest}
- {@link oaj.http.response.Conflict}
- {@link oaj.http.response.ExpectationFailed}
- {@link oaj.http.response.FailedDependency}
- {@link oaj.http.response.Forbidden}
- {@link oaj.http.response.Gone}
- {@link oaj.http.response.HttpVersionNotSupported}
- {@link oaj.http.response.InsufficientStorage}
- {@link oaj.http.response.InternalServerError}
- {@link oaj.http.response.LengthRequired}
- {@link oaj.http.response.Locked}
- {@link oaj.http.response.LoopDetected}
- {@link oaj.http.response.MethodNotAllowed}
- {@link oaj.http.response.MisdirectedRequest}
- {@link oaj.http.response.NetworkAuthenticationRequired}
- {@link oaj.http.response.NotAcceptable}
- {@link oaj.http.response.NotExtended}
- {@link oaj.http.response.NotFound}
- {@link oaj.http.response.NotImplemented}
- {@link oaj.http.response.PayloadTooLarge}
- {@link oaj.http.response.PreconditionFailed}
- {@link oaj.http.response.PreconditionRequired}
- {@link oaj.http.response.RangeNotSatisfiable}
- {@link oaj.http.response.RequestHeaderFieldsTooLarge}
- {@link oaj.http.response.ServiceUnavailable}
- {@link oaj.http.response.TooManyRequests}
- {@link oaj.http.response.Unauthorized}
- {@link oaj.http.response.UnavailableForLegalReasons}
- {@link oaj.http.response.UnprocessableEntity}
- {@link oaj.http.response.UnsupportedMediaType}
- {@link oaj.http.response.UpgradeRequired}
- {@link oaj.http.response.UriTooLong}
- {@link oaj.http.response.VariantAlsoNegotiates}
- Annotated throwables:
- {@link oaj.http.annotation.Response}
All other throwables get processed as follows:
- Processed as 400/Bad Request:
- {@link oaj.parser.ParseException}
- {@link oaj.InvalidDataConversionException}
- Processed as 401/Unauthorized:
- Any class named "*AccessDenied*" or "*Unauthorized*"
- Processed as 404/Not Found:
- Any class named "*Empty*" or "*NotFound*"
- Anything else processed as 500/Internal Server Error.
| @RestGet("/user/login")
| public Ok login(
| @FormData("username") String username,
| @FormData("password") String password
| ) throws Unauthorized
| {
| if (! isOK(username, password))
| throw new Unauthorized("You're not welcome!");
|
| return Ok.OK;
| }