/** * Will shut down the server displaying the cause and time of the shutdown * * @param e the exception that caused the shutdown */ public void shutdown(Throwable e) throws MuleException { I18nMessage msg = fatalErrorWhileRunning(); MuleException muleException = getRootMuleException(e); if (muleException != null) { logger.error(muleException.getDetailedMessage()); } else { logger.error(msg.toString() + " " + e.getMessage(), e); } List<String> msgs = new ArrayList<>(); msgs.add(msg.getMessage()); Throwable root = getRootException(e); msgs.add(root.getMessage() + " (" + root.getClass().getName() + ")"); msgs.add(" "); msgs.add(fatalErrorInShutdown().getMessage()); String shutdownMessage = getBoilerPlate(msgs, '*', 80); logger.error(shutdownMessage); doShutdown(); System.exit(1); }
private Optional<MetadataResult<?>> initializeComponent(Location location) { try { lazyMuleArtifactContext.initializeComponent(location, false); } catch (Exception e) { Throwable rootCause = getRootException(e); MetadataFailure.Builder builder = newFailure(e).withMessage(rootCause.getMessage()); if (rootCause instanceof NoSuchComponentModelException) { builder.withFailureCode(COMPONENT_NOT_FOUND); } return of(failure(builder.onComponent())); } return empty(); }
/** * {@inheritDoc} */ @Override public Set<Value> getValues(String parameterName) throws ValueResolvingException { try { return runWithValueProvidersContext(context -> withContextClassLoader(classLoader, () -> valueProviderMediator .getValues(parameterName, getParameterValueResolver(), (CheckedSupplier<Object>) () -> context .getConnection().orElse(null), (CheckedSupplier<Object>) () -> context .getConfig().orElse(null)))); } catch (MuleRuntimeException e) { Throwable rootException = getRootException(e); if (rootException instanceof ValueResolvingException) { throw (ValueResolvingException) rootException; } else { throw new ValueResolvingException("An unknown error occurred trying to resolve values. " + e.getCause().getMessage(), UNKNOWN, e); } } catch (Exception e) { throw new ValueResolvingException("An unknown error occurred trying to resolve values. " + e.getCause().getMessage(), UNKNOWN, e); } }
private Optional<ValueResult> initializeComponent(Location location) { Location locationWithOutConnection = locationWithOutConnection(location); try { lazyComponentInitializer.initializeComponent(locationWithOutConnection, false); } catch (Exception e) { Throwable rootException = getRootException(e); if (rootException instanceof NoSuchComponentModelException) { return of(resultFrom(newFailure(e) .withFailureCode(INVALID_LOCATION) .withMessage(format("Unable to resolve values. No component was found in the given location [%s]", location)) .build())); } return of(resultFrom(newFailure(e) .withMessage("Unknown error occurred trying to resolve values. " + e.getMessage()) .withFailureCode(UNKNOWN) .build())); } return empty(); }
@Test public void nestedExceptionRetrieval() throws Exception { Exception testException = getException(); Throwable t = getRootException(testException); assertNotNull(t); assertThat(t.getMessage(), is("blah")); assertThat(t.getCause(), nullValue()); t = getRootMuleException(testException); assertThat(t.getMessage(), is("bar")); assertThat(t.getCause(), not(nullValue())); List<Throwable> l = getExceptionsAsList(testException); assertThat(l, hasSize(3)); Map<String, Object> info = getExceptionInfo(testException); assertThat(info.entrySet(), hasSize(2)); assertThat(info, hasEntry("info_1", "Imma in!")); assertThat(info, hasEntry("info_2", "Imma out!")); }
private Optional<MetadataResult<?>> initializeComponent(Location location) { try { lazyMuleArtifactContext.initializeComponent(location, false); } catch (Exception e) { Throwable rootCause = getRootException(e); MetadataFailure.Builder builder = newFailure(e).withMessage(rootCause.getMessage()); if (rootCause instanceof NoSuchComponentModelException) { builder.withFailureCode(COMPONENT_NOT_FOUND); } return of(failure(builder.onComponent())); } return empty(); }
/** * Will shut down the server displaying the cause and time of the shutdown * * @param e the exception that caused the shutdown */ public void shutdown(Throwable e) throws MuleException { I18nMessage msg = fatalErrorWhileRunning(); MuleException muleException = getRootMuleException(e); if (muleException != null) { logger.error(muleException.getDetailedMessage()); } else { logger.error(msg.toString() + " " + e.getMessage(), e); } List<String> msgs = new ArrayList<>(); msgs.add(msg.getMessage()); Throwable root = getRootException(e); msgs.add(root.getMessage() + " (" + root.getClass().getName() + ")"); msgs.add(" "); msgs.add(fatalErrorInShutdown().getMessage()); String shutdownMessage = getBoilerPlate(msgs, '*', 80); logger.error(shutdownMessage); doShutdown(); System.exit(1); }
private Optional<ValueResult> initializeComponent(Location location) { Location locationWithOutConnection = locationWithOutConnection(location); try { lazyComponentInitializer.initializeComponent(locationWithOutConnection, false); } catch (Exception e) { Throwable rootException = getRootException(e); if (rootException instanceof NoSuchComponentModelException) { return of(resultFrom(newFailure(e) .withFailureCode(INVALID_LOCATION) .withMessage(format("Unable to resolve values. No component was found in the given location [%s]", location)) .build())); } return of(resultFrom(newFailure(e) .withMessage("Unknown error occurred trying to resolve values. " + e.getMessage()) .withFailureCode(UNKNOWN) .build())); } return empty(); }
/** * {@inheritDoc} */ @Override public Set<Value> getValues(String parameterName) throws ValueResolvingException { try { return runWithValueProvidersContext(context -> withContextClassLoader(getClassLoader(this.extensionModel), () -> valueProviderMediator .getValues(parameterName, getParameterValueResolver(), (CheckedSupplier<Object>) () -> context .getConnection().orElse(null), (CheckedSupplier<Object>) () -> context .getConfig().orElse(null)))); } catch (MuleRuntimeException e) { Throwable rootException = getRootException(e); if (rootException instanceof ValueResolvingException) { throw (ValueResolvingException) rootException; } else { throw new ValueResolvingException("An unknown error occurred trying to resolve values. " + e.getCause().getMessage(), UNKNOWN, e); } } catch (Exception e) { throw new ValueResolvingException("An unknown error occurred trying to resolve values. " + e.getCause().getMessage(), UNKNOWN, e); } }
@Test public void nestedExceptionRetrieval() throws Exception { Exception testException = getException(); Throwable t = getRootException(testException); assertNotNull(t); assertThat(t.getMessage(), is("blah")); assertThat(t.getCause(), nullValue()); t = getRootMuleException(testException); assertThat(t.getMessage(), is("bar")); assertThat(t.getCause(), not(nullValue())); List<Throwable> l = getExceptionsAsList(testException); assertThat(l, hasSize(3)); Map<String, Object> info = getExceptionInfo(testException); assertThat(info.entrySet(), hasSize(2)); assertThat(info, hasEntry("info_1", "Imma in!")); assertThat(info, hasEntry("info_2", "Imma out!")); }