List of usage examples for org.springframework.core NestedRuntimeException getMessage
@Override
@Nullable
public String getMessage()
From source file:com.wandrell.example.swss.client.console.ConsoleClient.java
/** * Calls the endpoint in the specified URI by using the received client. * <p>// w w w. j a va 2s . c om * This client is expected to be prepared for calling the endpoint, which * mostly means being set up for the same security protocol it uses. * <p> * If an exception occurs while using the client an error warning will be * printed in the console. * * @param client * client which will call the endpoint * @param uri * URI for the endpoint * @param output * output for the client to print information * @param scanner * scanner for the input */ private static final void callEndpoint(final EntityClient client, final String uri, final PrintStream output, final Scanner scanner) { final ExampleEntity entity; // Queried entity final Integer id; // Id for the query output.println("------------------------------------"); output.println("Write the id of the entity to query."); output.println("The id 1 is always valid."); output.println("------------------------------------"); output.println(); output.print("Id: "); id = getInteger(scanner); output.println(); try { entity = client.getEntity(uri, id); if ((entity == null) || (entity.getId() < 0)) { // No entity found output.println(String.format("No entity with id %d exists", id)); } else { // Entity found output.println("Found entity."); output.println(); output.println(String.format("Entity id:\t%d", entity.getId())); output.println(String.format("Entity name:\t%s", entity.getName())); } } catch (final NestedRuntimeException e) { output.println(String.format("Error: %s", e.getMostSpecificCause().getMessage())); } catch (final Exception e) { output.println(String.format("Error: %s", e.getMessage())); } // Waits so the result information can be checked waitForEnter(output, scanner); }