001/*
002 * JPPF.
003 * Copyright (C) 2005-2019 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 JPPFTaskSerializationException extends Throwable {
026  /**
027   * Explicit serialVersionUID.
028   */
029  private static final long serialVersionUID = 1L;
030
031  /**
032   * Initialize this exception.
033   * @param message the exception message.
034   * @param stackTrace the stack trace to set onto this exception.
035   */
036  public JPPFTaskSerializationException(final String message, final StackTraceElement[] stackTrace) {
037    super(message, null, false, true);
038    if (stackTrace != null) setStackTrace(stackTrace);
039  }
040
041  /**
042   * Initialize this exception from the specified {@code Throwable}.
043   * @param throwable the {@code Throwable} to get information from.
044   */
045  public JPPFTaskSerializationException(final Throwable throwable) {
046    super(String.format("[%s: %s]", throwable.getClass().getName(), throwable.getMessage()), null, false, true);
047    final StackTraceElement[] stackTrace = throwable.getStackTrace();
048    if (stackTrace != null) setStackTrace(stackTrace);
049  }
050}