001/**
002 * RenameWand 2.2
003 * Copyright 2007 Zach Scrivena
004 * 2007-12-09
005 * zachscrivena@gmail.com
006 * http://renamewand.sourceforge.net/
007 *
008 * RenameWand is a simple command-line utility for renaming files or
009 * directories using an intuitive but powerful syntax.
010 *
011 * TERMS AND CONDITIONS:
012 * This program is free software: you can redistribute it and/or modify
013 * it under the terms of the GNU General Public License as published by
014 * the Free Software Foundation, either version 3 of the License, or
015 * (at your option) any later version.
016 *
017 * This program is distributed in the hope that it will be useful,
018 * but WITHOUT ANY WARRANTY; without even the implied warranty of
019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
020 * GNU General Public License for more details.
021 *
022 * You should have received a copy of the GNU General Public License
023 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
024 */
025
026package ca.bc.webarts.tools.renamewand;
027
028
029/**
030 * Represent a runtime exception that terminates the program.
031 * This exception should be allowed to propagate to the top-level for proper handling.
032 */
033class TerminatingException
034    extends RuntimeException
035{
036  /** exit status code to be reported to the OS */
037  private final int exitCode;
038
039
040  /**
041   * Constructor.
042   *
043   * @param message
044   *      Exception message; saved for later retrieval by the Throwable.getMessage() method
045   * @param exitCode
046   *      Exit status code; saved for later retrieval by the TerminatingException.getExitCode()
047   *      method
048   */
049  TerminatingException(
050      final String message,
051      final int exitCode)
052  {
053    super(message);
054    this.exitCode = exitCode;
055  }
056
057
058  /**
059   * Constructor. Exit status code is assumed to be 1.
060   *
061   * @param message
062   *      Exception message; saved for later retrieval by the Throwable.getMessage() method
063   */
064  TerminatingException(
065      final String message)
066  {
067    super(message);
068    this.exitCode = 1;
069  }
070
071
072  /**
073   * Return the exit status code to be reported to the OS.
074   */
075  int getExitCode()
076  {
077    return this.exitCode;
078  }
079}