001/*
002 * JPPF.
003 * Copyright (C) 2005-2015 JPPF Team.
004 * http://www.jppf.org
005 *
006 * Licensed under the Apache License, Version 2.0 (the "License");
007 * you may not use this file except in compliance with the License.
008 * You may obtain a copy of the License at
009 *
010 *   http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018
019package org.jppf.node.protocol;
020
021/**
022 *
023 * @author Laurent Cohen
024 */
025public class JPPFExceptionResultEx extends JPPFExceptionResult {
026  /**
027   * Explicit serialVersionUID.
028   */
029  private static final long serialVersionUID = 1L;
030  /**
031   * These fields describe the {@code Throwable} object.
032   */
033  protected String throwableMessage, throwableClassName;
034  /**
035   * The throwable object's stack trace.
036   */
037  protected StackTraceElement[] throwableStackTrace;
038
039  /**
040   * Default constructor provided as a convenience for subclassing.
041   */
042  public JPPFExceptionResultEx() {
043    super();
044  }
045
046  /**
047   * Initialize this task with the specified error context.
048   * @param throwable the throwable that is to be captured.
049   * @param object the object on which the throwable applies.
050   */
051  public JPPFExceptionResultEx(final Throwable throwable, final Object object) {
052    super(null, object);
053    if (throwable != null) {
054      throwableMessage = throwable.getMessage();
055      throwableStackTrace = throwable.getStackTrace();
056      throwableClassName = throwable.getClass().getName();
057    }
058  }
059
060  /**
061   * Get the message of the throwable.
062   * @return the message as a string.
063   */
064  public String getThrowableMessage() {
065    return throwableMessage;
066  }
067
068  /**
069   * Get the stack trace of the throwable.
070   * @return the stack trace as an array of {@code StackTraceElement}s.
071   */
072  public StackTraceElement[] getThrowableStackTrace() {
073    return throwableStackTrace;
074  }
075
076  /**
077   * Get the class name of the throwable.
078   * @return the class name as a string.
079   */
080  public String getThrowableClassName() {
081    return throwableClassName;
082  }
083}