ExceptionStack exceptionStack = new ExceptionStack();
final String url = OntConfig.getOntologyDbUrl(); final ResultSet resultSet = SparqlHttp.sparqlQuery(query, url, 0); ExceptionStack exceptionStack = new ExceptionStack();
final ExceptionStack exceptionStack = new ExceptionStack();
final ExceptionStack exceptionStack = new ExceptionStack(); String currentObservationId = "";
/** * Method detects the service states of the given service type. * * @param serviceType the type of the service states. * @throws CouldNotPerformException is thrown if the detection fails. */ private void detectAndRegisterServiceStates(final ServiceType serviceType) throws CouldNotPerformException { try { final MultiException.ExceptionStack exceptionStack = new MultiException.ExceptionStack(); Services.getServiceStateValues(serviceType).forEach((stateValue) -> { try { // filter unknown state values if (stateValue.name().equals("UNKNOWN")) { return; } // add built service state registerServiceState(Services.buildServiceState(serviceType, stateValue)); } catch (final Exception ex) { MultiException.push(this, ex, exceptionStack); } }); MultiException.checkAndThrow("Could not generate all service values!", exceptionStack); } catch (CouldNotPerformException ex) { throw new CouldNotPerformException("Could not generate service states!", ex); } } }
/** * Method checks the input reference is equal null and returns the reference in each case. If the reference is null, * an exception is stacked. Check the exceptionStack in each case. * * @param reference is the object, which should be checked. * @param source is the source of the reference. Can be ignored by null. * @param errorMessage is the exception message to use if the reference is null. * @param exceptionStack is used to bundle possible exception. Should be not null! * @return the reference and indirect the exceptionStack with possible new entry. */ static <T> T checkNotNull(final T reference, final Object source, final String errorMessage, ExceptionStack exceptionStack) { assert exceptionStack != null; if (reference == null) { final String message = (errorMessage == null) ? "Reference is null." : errorMessage; exceptionStack = initializeIfNull(exceptionStack); // to prevent NPE only exceptionStack.push(source, new NotAvailableException(message)); } return reference; }
private void initServiceSimulators(final UnitController unitController) throws InitializationException, InterruptedException { try { final MultiException.ExceptionStack exceptionStack = new MultiException.ExceptionStack(); for (final ServiceDescription serviceDescription : unitController.getUnitTemplate().getServiceDescriptionList()) { try { serviceSimulatorList.add(serviceSimulatorFactory.newInstance(unitController, serviceDescription.getType())); } catch (final CouldNotPerformException ex) { MultiException.push(this, ex, exceptionStack); } } try { MultiException.checkAndThrow("Could not init all service simulators!", exceptionStack); } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory(ex, LOGGER); } } catch (CouldNotPerformException ex) { throw new InitializationException(this, ex); } }
/** * Method ensures that one or multiple object reference(s) passed as a parameter to the calling method is/are not * null. Throws Exception otherwise. * * @param source is the source of the reference(s). Can be ignored by NULL. * @param objects are the reference parameter, which should be checked. * @throws MultiException is thrown in case at least one reference parameter is NULL. */ static void multipleCheckNotNullAndThrow(final Object source, final Object... objects) throws MultiException { final ExceptionStack exceptionStack = new ExceptionStack(); for (int i = 0; i < objects.length; i++) { try { checkNotNull(objects[i], "Parameter " + i + " in argument array is null!"); } catch (NotAvailableException e) { MultiException.push(source, e, exceptionStack); } } MultiException.checkAndThrow("Input is invalid.", exceptionStack); }
/** * Method initializes the input exceptionStack if it's null. * * @param exceptionStack which should be initialized. * @return an initialized and empty exceptionStack if input is null. Otherwise the unchanged input exceptionStack. */ static ExceptionStack initializeIfNull(ExceptionStack exceptionStack) { exceptionStack = (exceptionStack == null) ? new ExceptionStack() : exceptionStack; return exceptionStack; }