| Modifier and Type | Field and Description |
|---|---|
protected LifecycleService |
lifecycleService |
protected ResultHandler |
resultHandler |
protected Router |
router |
| Constructor and Description |
|---|
NinjaDefault() |
| Modifier and Type | Method and Description |
|---|---|
protected Message |
buildErrorMessage(Context context,
String errorTextKey,
String errorTextDefault,
Optional<Throwable> exception,
Optional<Result> underlyingResult) |
Result |
getBadRequestResult(Context context,
BadRequestException exception)
Should handle cases where the client sent strange date that
led to an error.
|
Result |
getForbiddenResult(Context context)
Should handle cases where access is forbidden
Should lead to a html error 403 - forbidden
(and be used with the same mindset).
|
Result |
getForbiddenResult(Context context,
ForbiddenRequestException exception)
Should handle cases where access is forbidden
Should lead to a html error 403 - forbidden
(and be used with the same mindset).
|
Result |
getInternalServerErrorResult(Context context,
Exception exception)
Deprecated.
|
Result |
getInternalServerErrorResult(Context context,
Exception exception,
Result underlyingResult)
Should handle cases where an exception is thrown
when handling a route that let to an internal server error.
|
Result |
getNotFoundResult(Context context)
Should handle cases where no route can be found for a given request.
|
Result |
getNotFoundResult(Context context,
RequestNotFoundException exception)
Should handle cases where no route can be found for a given request.
|
Result |
getRenderingExceptionResult(Context context,
RenderingException exception,
Result underlyingResult)
Should handle cases where a
RenderingException is thrown
when handling the rendering of a Result. |
Result |
getUnauthorizedResult(Context context)
Should handle cases where access is unauthorized
Should lead to a html error 401 - unauthorized
(and be used with the same mindset).
|
boolean |
isDiagnosticsEnabled()
Whether diagnostics are enabled.
|
Result |
onException(Context context,
Exception exception)
This result should be used when an error occurs.
|
Result |
onException(Context context,
Exception exception,
Result underlyingResult) |
void |
onFrameworkShutdown()
Invoked when the server hosting Ninja is being stopped.
|
void |
onFrameworkStart()
Invoked when the framework starts.
|
void |
onRouteRequest(Context.Impl context)
When a route is requested this method is called.
|
void |
renderErrorResultAndCatchAndLogExceptions(Result result,
Context context)
Should be used to render an error.
|
@Inject protected LifecycleService lifecycleService
@Inject protected Router router
@Inject protected ResultHandler resultHandler
public boolean isDiagnosticsEnabled()
public void onRouteRequest(Context.Impl context)
NinjaonRouteRequest in interface Ninjapublic void renderErrorResultAndCatchAndLogExceptions(Result result, Context context)
NinjarenderErrorResultAndCatchAndLogExceptions in interface Ninjapublic void onFrameworkStart()
NinjaonFrameworkStart in interface Ninjapublic void onFrameworkShutdown()
NinjaonFrameworkShutdown in interface Ninjapublic Result onException(Context context, Exception exception)
NinjaonException in interface Ninjacontext - The context for this requestexception - The exception to handle. Can be used to customize error message.public Result onException(Context context, Exception exception, Result underlyingResult)
public Result getRenderingExceptionResult(Context context, RenderingException exception, Result underlyingResult)
NinjaRenderingException is thrown
when handling the rendering of a Result.
Should lead to an html error 500 -- internal server error. If no special
handling is required, simply:
return getInternalServerErrorResult(context, exception, underlyingResult);
getRenderingExceptionResult in interface Ninja@Deprecated public Result getInternalServerErrorResult(Context context, Exception exception)
Ninja.getInternalServerErrorResult(Context, Exception, Result).public Result getInternalServerErrorResult(Context context, Exception exception, Result underlyingResult)
NinjagetInternalServerErrorResult in interface Ninjapublic Result getNotFoundResult(Context context)
NinjagetNotFoundResult in interface Ninjapublic Result getNotFoundResult(Context context, RequestNotFoundException exception)
NinjagetNotFoundResult in interface Ninjapublic Result getBadRequestResult(Context context, BadRequestException exception)
NinjagetBadRequestResult in interface Ninjapublic Result getUnauthorizedResult(Context context)
NinjagetUnauthorizedResult in interface Ninjapublic Result getForbiddenResult(Context context)
NinjagetForbiddenResult in interface Ninjapublic Result getForbiddenResult(Context context, ForbiddenRequestException exception)
NinjagetForbiddenResult in interface NinjaCopyright © 2019 ninjaframework. All rights reserved.