001 /* 002 * CDDL HEADER START 003 * 004 * The contents of this file are subject to the terms of the 005 * Common Development and Distribution License, Version 1.0 only 006 * (the "License"). You may not use this file except in compliance 007 * with the License. 008 * 009 * You can obtain a copy of the license at 010 * trunk/opends/resource/legal-notices/OpenDS.LICENSE 011 * or https://OpenDS.dev.java.net/OpenDS.LICENSE. 012 * See the License for the specific language governing permissions 013 * and limitations under the License. 014 * 015 * When distributing Covered Code, include this CDDL HEADER in each 016 * file and include the License file at 017 * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, 018 * add the following below this CDDL HEADER, with the fields enclosed 019 * by brackets "[]" replaced with your own identifying information: 020 * Portions Copyright [yyyy] [name of copyright owner] 021 * 022 * CDDL HEADER END 023 * 024 * 025 * Copyright 2006-2008 Sun Microsystems, Inc. 026 */ 027 package org.opends.server.tools; 028 import org.opends.messages.Message; 029 030 031 032 import org.opends.server.types.IdentifiedException; 033 034 035 036 /** 037 * This class defines an exception that may be thrown if a local problem occurs 038 * in a Directory Server client. 039 */ 040 public class ClientException 041 extends IdentifiedException 042 { 043 /** 044 * The serial version identifier required to satisfy the compiler because this 045 * class extends <CODE>java.lang.Exception</CODE>, which implements the 046 * <CODE>java.io.Serializable</CODE> interface. This value was generated 047 * using the <CODE>serialver</CODE> command-line utility included with the 048 * Java SDK. 049 */ 050 private static final long serialVersionUID = 1384120263337669664L; 051 052 053 054 // The exit code that may be used if the client considers this to be a fatal 055 // problem. 056 private int exitCode; 057 058 059 060 /** 061 * Creates a new client exception with the provided message. 062 * 063 * @param exitCode The exit code that may be used if the client considers 064 * this to be a fatal problem. 065 * @param message The message that explains the problem that occurred. 066 */ 067 public ClientException(int exitCode, Message message) 068 { 069 super(message); 070 071 this.exitCode = exitCode; 072 } 073 074 075 076 /** 077 * Creates a new client exception with the provided message and root cause. 078 * 079 * @param exitCode The exit code that may be used if the client considers 080 * this to be a fatal problem. 081 * @param message The message that explains the problem that occurred. 082 * @param cause The exception that was caught to trigger this exception. 083 */ 084 public ClientException(int exitCode, Message message, Throwable cause) 085 { 086 super(message, cause); 087 088 this.exitCode = exitCode; 089 } 090 091 092 093 /** 094 * Retrieves the exit code that the client may use if it considers this to be 095 * a fatal problem. 096 * 097 * @return The exit code that the client may use if it considers this to be 098 * a fatal problem. 099 */ 100 public int getExitCode() 101 { 102 return exitCode; 103 } 104 105 106 } 107