Search in sources :

Example 1 with SimulateInternalError

use of org.webpieces.router.impl.routers.SimulateInternalError in project webpieces by deanhiller.

the class DevRouteInvoker method invokeErrorController.

@Override
public XFuture<Void> invokeErrorController(InvokeInfo invokeInfo, Endpoint dynamicInfo, RouteData data) {
    RouteInfoForInternalError error = (RouteInfoForInternalError) data;
    Throwable exception = error.getException();
    if (exception instanceof SimulateInternalError) {
        // just use the original route at this point
        return super.invokeErrorController(invokeInfo, dynamicInfo, data);
    }
    return invokeDevelopmentErrorPage(invokeInfo, error);
}
Also used : RouteInfoForInternalError(org.webpieces.router.impl.services.RouteInfoForInternalError) SimulateInternalError(org.webpieces.router.impl.routers.SimulateInternalError)

Example 2 with SimulateInternalError

use of org.webpieces.router.impl.routers.SimulateInternalError in project webpieces by deanhiller.

the class DevRouteInvoker method invokeHtmlController.

@Override
public RouterStreamRef invokeHtmlController(InvokeInfo invokeInfo, StreamService dynamicInfo, RouteData data) {
    // special case for if stuff didn't compile and we flag it
    Throwable exc = (Throwable) invokeInfo.getRequestCtx().getRequest().requestState.get(ERROR_KEY);
    if (exc != null) {
        log.error("Could not compile your code", exc);
        RouteInfoForInternalError error = new RouteInfoForInternalError(exc);
        XFuture<Void> future = invokeDevelopmentErrorPage(invokeInfo, error);
        XFuture<StreamWriter> writer = future.thenApply(voidd -> new NullWriter());
        return new RouterStreamRef("notCompileError", writer, null);
    }
    if (invokeInfo.getRequestCtx().getRequest().queryParams.containsKey(DevelopmentController.INTERNAL_ERROR_KEY)) {
        // need to simulate the error to show production page
        throw new SimulateInternalError();
    }
    // }
    return super.invokeHtmlController(invokeInfo, dynamicInfo, data);
}
Also used : StreamWriter(com.webpieces.http2.api.streaming.StreamWriter) RouteInfoForInternalError(org.webpieces.router.impl.services.RouteInfoForInternalError) SimulateInternalError(org.webpieces.router.impl.routers.SimulateInternalError) NullWriter(org.webpieces.router.impl.routeinvoker.NullWriter) RouterStreamRef(org.webpieces.router.impl.routeinvoker.RouterStreamRef)

Aggregations

SimulateInternalError (org.webpieces.router.impl.routers.SimulateInternalError)2 RouteInfoForInternalError (org.webpieces.router.impl.services.RouteInfoForInternalError)2 StreamWriter (com.webpieces.http2.api.streaming.StreamWriter)1 NullWriter (org.webpieces.router.impl.routeinvoker.NullWriter)1 RouterStreamRef (org.webpieces.router.impl.routeinvoker.RouterStreamRef)1