Method exists the application and prints the given exception as error description.

@param ex the reason for the application exit.
345185
public static void exit(final int exitCode, final Exception ex) {
        System.err.println(JPService.getApplicationName() + " crashed...");
        ExceptionPrinter.printHistory(ex, System.err);
        System.exit(exitCode);
    }
802199
public void setMessageException(Throwable ex)
    {
        String strErrorMessage = ex.getMessage();
        BaseMessage message = this.getMessage();
        if ((message != null) && (message.getMessageHeader() instanceof TrxMessageHeader))
            ((TrxMessageHeader)message.getMessageHeader()).put(TrxMessageHeader.MESSAGE_ERROR, strErrorMessage);
        else
            ex.printStackTrace();
    }
172822
public void setErrorReturn(PrintWriter out, RemoteException ex)
        throws RemoteException
    {
        out.println(Utility.startTag(XMLTags.STATUS_TEXT));
        String strMessage = ex.getLocalizedMessage();
        if (Utility.isNumeric(strMessage))
        {
            try {
                int iErrorCode = Integer.parseInt(strMessage);
                out.println(Utility.startTag(XMLTags.ERROR_CODE) + strMessage + Utility.endTag(XMLTags.ERROR_CODE));
                if (this.getTask() != null)
                    if (this.getTask().getApplication() != null)
                        strMessage = this.getTask().getApplication().getSecurityErrorText(iErrorCode);
            } catch (NumberFormatException ex2) {
                // Ignore
            }
        }
        out.println(Utility.startTag(XMLTags.TEXT) + strMessage + Utility.endTag(XMLTags.TEXT));
        out.println(Utility.startTag(XMLTags.ERROR) + "error" + Utility.endTag(XMLTags.ERROR));
        out.println(Utility.endTag(XMLTags.STATUS_TEXT));
        return;
    }
576428
private void handleWriteException(Throwable ex) {
        if (ex instanceof ObjectClosedException && !this.closed.get()) {
            log.warn("{}: Caught ObjectClosedException but not closed; closing now.", this.traceObjectId, ex);
            close();
        }
    }
1287531
private static void throwCause(final ExecutionException ex) {
        if (ex.getCause() instanceof RuntimeException) {
            throw (RuntimeException) ex.getCause();
        }

        if (ex.getCause() instanceof Error) {
            throw (Error) ex.getCause();
        }
    }
3825
@ExceptionHandler(Exception.class)
    public ResponseEntity handleException(Exception ex) {
        EXC_LOGGER.error("[P] Presentation Layer Exception: " + ex.getLocalizedMessage(), ex);
        if (ex instanceof BehaviorAwareException) {
            BehaviorAwareException bae = (BehaviorAwareException) ex;
            return bae.toResponse(bae.getData());
        }
        if (ex instanceof BusinessRuntimeException) {
            BusinessRuntimeException bre = (BusinessRuntimeException) ex;
            return new ResponseEntity<>(Response.newBuilder()
                    .withMessage(bre.getMessage())
                    .withHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR.toString())
                    .withObj(new String[]{bre.getMessageKey()})
                    .build(),
                    HttpStatus.INTERNAL_SERVER_ERROR
            );
        }
        if (ex instanceof HttpBusinessException) {
            HttpBusinessException e = (HttpBusinessException) ex;
            return new ResponseEntity<>(Response.newBuilder()
                    .withMessage(ex.getMessage())
                    .withHttpStatus(e.getHttpStatus().toString())
                    .build(),
                    e.getHttpStatus()
            );
        }
        if (ex instanceof ValidationException) {
            return new ResponseEntity<>(Response.newBuilder()
                    .withMessage(ex.getMessage())
                    .withHttpStatus(HttpStatus.BAD_REQUEST.toString())
                    .build(),
                    HttpStatus.BAD_REQUEST
            );
        }
        if (ex instanceof TechnicalRuntimeException) {
            return new ResponseEntity<>(Response.newBuilder()
                    .withMessage(ex.getMessage())
                    .withHttpStatus(HttpStatus.BAD_GATEWAY.toString())
                    .build(),
                    HttpStatus.BAD_GATEWAY
            );
        }
        return new ResponseEntity<>(Response.newBuilder()
                .withMessage(ex.getMessage())
                .withHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR.toString())
                .build(),
                HttpStatus.INTERNAL_SERVER_ERROR
        );
    }
125441
public synchronized void setException(Throwable ex) {
    if(_ex == null) {
      _ex = AutoBuffer.javaSerializeWritePojo(((ex instanceof DistributedException) ? (DistributedException) ex : new DistributedException(ex,false /* don't want this setException(ex) call in the stacktrace */)));
    }
  }
447597
def exception_handler(self, ex):  # pylint: disable=no-self-use
        
        if isinstance(ex, CLIError):
            logger.error(ex)
        else:
            logger.exception(ex)
        return 1
282826
public void error(MEConnection conn, Throwable ex)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "error", new Object[] { this, conn, ex});

    // This one goes straight to the CEL
    _commsErrorListener.error(conn, ex);

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "error");
  }
694831
public function logException(\Exception $ex,$prefix="ex")
    {
        $this->log($ex->getCode().":".$ex->getMessage()."\r\n".$ex->getTraceAsString(),get_class($ex),$prefix);
    }
457038
public void cancel(Throwable ex){
    if(ex instanceof JobCancelledException || ex.getMessage() != null && ex.getMessage().contains("job was cancelled"))
      return;
    if(ex instanceof  IllegalArgumentException || ex.getCause() instanceof IllegalArgumentException) {
      cancel("Illegal argument: " + ex.getMessage());
      return;
    }
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    ex.printStackTrace(pw);
    String stackTrace = sw.toString();
    cancel("Got exception '" + ex.getClass() + "', with msg '" + ex.getMessage() + "'\n" + stackTrace, JobState.FAILED);
    if(_fjtask != null && !_fjtask.isDone()) _fjtask.completeExceptionally(ex);
  }
1152030
void internalPropagateException(Throwable ex) {
    CountedCompleter<?> a = this, s = a;
    while (a.onExceptionalCompletion(ex, s) && (a = (s = a).completer) != null && a.status >= 0
        && a.recordExceptionalCompletion(ex) == EXCEPTIONAL);
  }
574459
public void onError( Exception e ) {
        e.printStackTrace();
        String localizedMessage = e.getLocalizedMessage();
        if (localizedMessage == null) {
            localizedMessage = e.getMessage();
        }
        if (localizedMessage == null || localizedMessage.trim().length() == 0) {
            localizedMessage = "An undefined error was thrown. Please send the below trace to your technical contact:\n";
            localizedMessage += ExceptionUtils.getStackTrace(e);
        }

        String _localizedMessage = localizedMessage;
        SwingUtilities.invokeLater(new Runnable(){
            public void run() {
                JOptionPane.showMessageDialog(parent, _localizedMessage, "ERROR", JOptionPane.ERROR_MESSAGE);
            }
        });
    }
395577
private static void expandThrowable(Throwable ex)
    {
        ex.printStackTrace(__printWriter);

        if (ex instanceof MultiException)
        {
            MultiException mx = (MultiException)ex;
            
            for (int i=0;i<mx.size();i++)
            {
                __printWriter.print("["+i+"]=");
                Throwable ex2=mx.getException(i);
                expandThrowable(ex2);
            }
        }
        else
        {
            for (int i=0;i<__nestedEx.length;i++)
            {
                try
                {
                    Method getTargetException =
                        ex.getClass().getMethod(__nestedEx[i],__noArgs);
                    Throwable ex2=(Throwable)getTargetException.invoke(ex,(java.lang.Object[])null);
                    if (ex2!=null)
                    {
                        __printWriter.println(__nestedEx[i]+"():");
                        expandThrowable(ex2);
                    }
                }
                catch(Exception ignore){}
            }
        }
    }
565913
protected static boolean isRecoverableException(AmazonServiceException ex) {
		if (ex.getErrorType() == null) {
			return false;
		}

		switch (ex.getErrorType()) {
			case Client:
				return ex instanceof ProvisionedThroughputExceededException;
			case Service:
			case Unknown:
				return true;
			default:
				return false;
		}
	}
981667
public void setNextException(SQLException ex) {

        SQLException current = this;
        for(;;) {
            SQLException next=current.next;
            if (next != null) {
                current = next;
                continue;
            }

            if (nextUpdater.compareAndSet(current,null,ex)) {
                return;
            }
            current=current.next;
        }
    }
427787
public DatabaseException convertError(Exception ex)
    {
        DatabaseException eDB = null;
        int iError = DBConstants.ERROR_RETURN;
        String strMessage = "Error!";
        if (ex != null)
            strMessage = ex.getMessage();
        if (ex instanceof SQLException)
        {
            SQLException sqlex = (SQLException)ex;
            String strState = sqlex.getSQLState();
            strMessage += strState;
            if (!m_bFirstErrorCheck)
            {
                m_bFirstErrorCheck = true;
                m_strFileNotFoundErrorText = (String)this.getProperties().get(SQLParams.TABLE_NOT_FOUND_ERROR_TEXT);
                if (m_strFileNotFoundErrorText != null)
                    m_strFileNotFoundErrorText = m_strFileNotFoundErrorText.toLowerCase();
                m_strFileNotFoundErrorCode = (String)this.getProperties().get(SQLParams.TABLE_NOT_FOUND_ERROR_CODE);
                m_strDBNotFoundErrorText = (String)this.getProperties().get(SQLParams.DB_NOT_FOUND_ERROR_TEXT);
                if (m_strDBNotFoundErrorText != null)
                    m_strDBNotFoundErrorText = m_strDBNotFoundErrorText.toLowerCase();
                m_strDBNotFoundErrorCode = (String)this.getProperties().get(SQLParams.DB_NOT_FOUND_ERROR_CODE);
                m_strDuplicateKeyErrorText = (String)this.getProperties().get(SQLParams.DUPLICATE_KEY_ERROR_TEXT);
                if (m_strDuplicateKeyErrorText != null)
                    m_strDuplicateKeyErrorText = m_strDuplicateKeyErrorText.toLowerCase();
                m_strDuplicateKeyErrorCode = (String)this.getProperties().get(SQLParams.DUPLICATE_KEY_ERROR_CODE);
                m_strKeyNotFoundErrorText = (String)this.getProperties().get(SQLParams.KEY_NOT_FOUND_ERROR_TEXT);
                if (m_strKeyNotFoundErrorText != null)
                    m_strKeyNotFoundErrorText = m_strDuplicateKeyErrorText.toLowerCase();
                m_strKeyNotFoundErrorCode = (String)this.getProperties().get(SQLParams.KEY_NOT_FOUND_ERROR_CODE);
                m_strRecordLockedErrorText = (String)this.getProperties().get(SQLParams.RECORD_LOCKED_ERROR_TEXT);
                if (m_strRecordLockedErrorText != null)
                    m_strRecordLockedErrorText = m_strRecordLockedErrorText.toLowerCase();
                m_strRecordLockedErrorCode = (String)this.getProperties().get(SQLParams.RECORD_LOCKED_ERROR_CODE);
                m_strBrokenPipeErrorText = (String)this.getProperties().get(SQLParams.BROKEN_PIPE_ERROR_TEXT);
                if (m_strBrokenPipeErrorText != null)
                    m_strBrokenPipeErrorText = m_strBrokenPipeErrorText.toLowerCase();
                m_strBrokenPipeErrorCode = (String)this.getProperties().get(SQLParams.BROKEN_PIPE_ERROR_CODE);
            }
                // Yeah, I know this is slow, but exceptions are not that common.
            if (this.checkForError(ex, DBConstants.FILE_NOT_FOUND, m_strFileNotFoundErrorText, m_strFileNotFoundErrorCode))
                iError = DBConstants.FILE_NOT_FOUND;
            if (this.checkForError(ex, DBConstants.DB_NOT_FOUND, m_strDBNotFoundErrorText, m_strDBNotFoundErrorCode))
                iError = DBConstants.DB_NOT_FOUND;
            if (this.checkForError(ex, DBConstants.DUPLICATE_KEY, m_strDuplicateKeyErrorText, m_strDuplicateKeyErrorCode))
                iError = DBConstants.DUPLICATE_KEY;
            if (this.checkForError(ex, DBConstants.DUPLICATE_COUNTER, m_strDuplicateKeyErrorText, m_strDuplicateKeyErrorCode))
                iError = DBConstants.DUPLICATE_COUNTER;
            if (this.checkForError(ex, DBConstants.KEY_NOT_FOUND, m_strKeyNotFoundErrorText, m_strKeyNotFoundErrorCode))
                iError = DBConstants.KEY_NOT_FOUND;
            if (this.checkForError(ex, DBConstants.RECORD_LOCKED, m_strRecordLockedErrorText, m_strRecordLockedErrorCode))
                iError = DBConstants.RECORD_LOCKED;
            if (this.checkForError(ex, DBConstants.BROKEN_PIPE, m_strBrokenPipeErrorText, m_strBrokenPipeErrorCode))
                iError = DBConstants.BROKEN_PIPE;
        }
        if (iError == DBConstants.ERROR_RETURN)
        {
            Utility.getLogger().info("Unknown sql exception: " + strMessage);
            eDB = new DatabaseException(strMessage);
        }
        else if (iError == DBConstants.RECORD_LOCKED)
            eDB = new DatabaseException(iError, strMessage);    // On locked, tells user/computer
        else
            eDB = new DatabaseException(iError);    // Standard error
        return eDB;
    }