protected IRequestablePage errorPageFor(Exception ex) { List<ExceptionRecognizer> exceptionRecognizers = Lists.newArrayList(); exceptionRecognizers.add(pageExpiredExceptionRecognizer); if(inIsisSession()) { exceptionRecognizers.addAll(getServicesInjector().lookupServices(ExceptionRecognizer.class)); } else { final MetaModelInvalidException mmie = IsisContext.getMetaModelInvalidExceptionIfAny(); if(mmie != null) { Set<String> validationErrors = mmie.getValidationErrors(); return new MmvErrorPage(validationErrors); } // not sure whether this can ever happen now... LOG.warn("Unable to obtain exceptionRecognizers (no session), will be treated as unrecognized exception", ex); } String recognizedMessageIfAny = new ExceptionRecognizerComposite(exceptionRecognizers).recognize(ex); ExceptionModel exceptionModel = ExceptionModel.create(recognizedMessageIfAny, ex); return isSignedIn() ? new ErrorPage(exceptionModel) : newSignInPage(exceptionModel); }
@Before public void setUp() throws Exception { composite = new ExceptionRecognizerComposite(); composite.container = mockContainer; composite.translationService = mockTranslationService; context.ignoring(mockContainer); context.ignoring(mockTranslationService); }