01: // ***************************************************************
02: // * *
03: // * File:ServiceException.java *
04: // * *
05: // * Copyright (c) 2002 Sun Microsystems, Inc. *
06: // * All rights reserved. *
07: // * *
08: // * *
09: // * Date - Jul/16/2002 *
10: // * Author - alejandro.abdelnur@sun.com *
11: // * *
12: // ***************************************************************
13:
14: package com.sun.portal.common.service;
15:
16: /**
17: * Defines a general exception a service can throw when it
18: * encounters difficulty.
19: * <P>
20: *
21: * @author <A HREF="mailto:tucu@sun.com">Alejandro Abdelnur</A>
22: *
23: */
24: public class ServiceException extends Exception {
25: private int _code;
26: private Throwable _cause;
27:
28: /**
29: * Constructs a new service exception with an error code,
30: * a message and a root exception.
31: * <P>
32: *
33: * @param code an int specifying the error code number
34: *
35: * @param msg a String specifying the text of the exception
36: * message
37: *
38: * @param cause the Throwable exception that interfered with
39: * the service's normal operation, making this service
40: * exception necessary
41: *
42: */
43: public ServiceException(int code, String msg, Throwable cause) {
44: super (msg);
45: _code = code;
46: _cause = cause;
47: }
48:
49: /**
50: * Returns the error code number of the exception.
51: * <P>
52: *
53: * @return the error code.
54: *
55: */
56: public int getCode() {
57: return _code;
58: }
59:
60: /**
61: * Returns the exception that caused this servlet exception.
62: * <P>
63: *
64: * @return the Throwable that caused this servlet exception
65: *
66: */
67: public Throwable getCause() {
68: return _cause;
69: }
70:
71: public String toString() {
72: return "ServiceException code[" + _code + "] msg["
73: + getMessage() + "] cause:\n" + _cause + "\n";
74: }
75:
76: }
|