Package org.mojavemvc.exception

Examples of org.mojavemvc.exception.ErrorHandler


       
        AppProperties properties = mock(AppProperties.class);
        when(properties.getProperty(DefaultJSPErrorHandler.JSP_ERROR_FILE))
            .thenReturn(errorJsp);

        ErrorHandler errorHandler = new DefaultJSPErrorHandler();
        View view = errorHandler.handleError(null, properties);

        assertTrue(view instanceof JSP);
        JSP jspView = (JSP) view;
        assertEquals(errorJsp, jspView.getJSPName());
    }
View Full Code Here


    @Test
    public void createErrorHandler() throws Exception {

        DefaultJSPErrorHandlerFactory factory = new DefaultJSPErrorHandlerFactory();
        ErrorHandler errorHandler = factory.createErrorHandler();

        assertTrue(errorHandler instanceof DefaultJSPErrorHandler);
    }
View Full Code Here

*/
public class HTMLErrorHandlerFactory implements ErrorHandlerFactory {

    @Override
    public ErrorHandler createErrorHandler() {
        return new ErrorHandler() {
            @Override
            public View handleError(Throwable e, AppProperties properties) {
                return new HTMLErrorPage();
            }
        };
View Full Code Here

    }
   
    @Test
    public void handleError_NullException() throws Exception {

        ErrorHandler errorHandler = new DefaultErrorHandler();
        View view = errorHandler.handleError(null, properties);

        assertTrue(view instanceof PlainText);
        PlainText stackTrace = (PlainText) view;
        assertEquals("", stackTrace.toString());
    }
View Full Code Here

    @Test
    public void handleError_WithException() throws Exception {

        Exception e = new Exception("testing");
       
        ErrorHandler errorHandler = new DefaultErrorHandler();
        View view = errorHandler.handleError(e, properties);

        assertTrue(view instanceof PlainText);
        PlainText stackTrace = (PlainText) view;
        assertTrue(stackTrace.toString().startsWith("java.lang.Exception: testing"));
    }
View Full Code Here

   
    @Test
    public void createErrorHandler() throws Exception {

        DefaultErrorHandlerFactory factory = new DefaultErrorHandlerFactory();
        ErrorHandler errorHandler = factory.createErrorHandler();

        assertTrue(errorHandler instanceof DefaultErrorHandler);
    }
View Full Code Here

            throws ServletException, IOException {
       
        ControllerDatabase controllerDb = (ControllerDatabase) ctx.getAttribute(ControllerDatabase.KEY);

        ErrorHandlerFactory errorHandlerFactory = (ErrorHandlerFactory) ctx.getAttribute(ErrorHandlerFactory.KEY);
        ErrorHandler errorHandler = errorHandlerFactory.createErrorHandler();

        Injector injector = (Injector) ctx.getAttribute(GuiceInitializer.KEY);
        AppProperties properties = (AppProperties) ctx.getAttribute(AppProperties.KEY);

        ServletResourceModule.set(req, res);

        View view;
        try {
           
            RequestRouter router = new HttpRequestRouter(path,
                    new HttpParameterMapSource(req), controllerDb.getRouter());
           
            RoutedRequest routed = router.route();
           
            ActionResolver resolver = new HttpActionResolver(ctx, req, httpMethod, controllerDb, injector);
   
            ActionInvoker invoker = new HttpActionInvoker(req, res, controllerDb, routed, injector);
   
            RequestProcessor requestProcessor = new RequestProcessor(resolver, invoker, errorHandler);
           
            view = requestProcessor.process(routed.getController(), routed.getAction(), properties);
   
            logger.debug("processed request for " + requestProcessor.getControllerClassName() + "; rendering...");

            view.render(req, res, properties);

        } catch (Throwable e) {

            logger.error("error processing request: ", e);
            view = errorHandler.handleError(e, properties);
            if (view != null) {
                /*
                 * we're not catching any exceptions thrown from rendering the
                 * error view
                 */
 
View Full Code Here

TOP

Related Classes of org.mojavemvc.exception.ErrorHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.