001: /*
002: * Portions Copyright 2000-2007 Sun Microsystems, Inc. All Rights
003: * Reserved. Use is subject to license terms.
004: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
005: *
006: * This program is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU General Public License version
008: * 2 only, as published by the Free Software Foundation.
009: *
010: * This program is distributed in the hope that it will be useful, but
011: * WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * General Public License version 2 for more details (a copy is
014: * included at /legal/license.txt).
015: *
016: * You should have received a copy of the GNU General Public License
017: * version 2 along with this work; if not, write to the Free Software
018: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
019: * 02110-1301 USA
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
022: * Clara, CA 95054 or visit www.sun.com if you need additional
023: * information or have any questions.
024: */
025: /*
026: */
027: package gov.nist.siplite.stack;
028:
029: import gov.nist.siplite.message.*;
030: import gov.nist.core.*;
031:
032: import com.sun.midp.log.Logging;
033: import com.sun.midp.log.LogChannels;
034:
035: /**
036: * Exception that gets generated when the Stack encounters an error.
037: *
038: * @version JAIN-SIP-1.1
039: *
040: *
041: * <a href="{@docRoot}/uncopyright.html">This code is in the public domain.</a>
042: *
043: */
044: public class SIPServerException extends Exception {
045: /** Return code. */
046: protected int rc;
047: /** Message. */
048: protected String message;
049: /** The saved SIP server message. */
050: protected Message sipMessage;
051:
052: /**
053: * Gets the reason code.
054: * @return the reason code
055: */
056: public int getRC() {
057: return this .rc;
058: }
059:
060: /**
061: * Constructor when we are given only the error code
062: * @param rc Return code.
063: */
064: public SIPServerException(int rc) {
065: this .rc = rc;
066:
067: if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
068: printStackTrace();
069: }
070: }
071:
072: /**
073: * Constructor for when we have the error code and some error info.
074: * @param rc SIP Return code
075: * @param msg Error message
076: */
077: public SIPServerException(int rc, String msg) {
078: this .rc = rc;
079: this .message = msg;
080:
081: if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
082: printStackTrace();
083: }
084: }
085:
086: /**
087: * Constructor for when we have a return code and a Message.
088: * @param rc SIP error code
089: * @param message SIP Error message
090: * @param msg Auxiliary error message
091: */
092: public SIPServerException(int rc, Message message, String msg) {
093: this .rc = rc;
094: this .sipMessage = message;
095: this .message = msg;
096:
097: if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
098: printStackTrace();
099: }
100: }
101:
102: /**
103: * Constructor when we have a pre-formatted response.
104: * @param response Pre-formatted response to send back to the
105: * other end.
106: */
107: public SIPServerException(String response) {
108: super (response);
109: ServerLog.logException(this );
110: }
111:
112: /**
113: * Constructor that constructs the message from the standard
114: * Error messages.
115: *
116: * @param rc is the SIP Error code.
117: * @param sipMessage is the SIP Message that caused the exception.
118: */
119: public SIPServerException(int rc, Message sipMessage) {
120: this .rc = rc;
121: this .sipMessage = sipMessage;
122: }
123:
124: /**
125: * Gets the message that generated this exception.
126: *
127: * @return -- the message that generated this exception.
128: */
129: public Message getSIPMessage() {
130: return this.sipMessage;
131: }
132:
133: }
|