xref: /onnv-gate/usr/src/lib/sun_fc/common/Exceptions.h (revision 7836:4e95154b5b7a)
1*7836SJohn.Forte@Sun.COM /*
2*7836SJohn.Forte@Sun.COM  * CDDL HEADER START
3*7836SJohn.Forte@Sun.COM  *
4*7836SJohn.Forte@Sun.COM  * The contents of this file are subject to the terms of the
5*7836SJohn.Forte@Sun.COM  * Common Development and Distribution License (the "License").
6*7836SJohn.Forte@Sun.COM  * You may not use this file except in compliance with the License.
7*7836SJohn.Forte@Sun.COM  *
8*7836SJohn.Forte@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*7836SJohn.Forte@Sun.COM  * or http://www.opensolaris.org/os/licensing.
10*7836SJohn.Forte@Sun.COM  * See the License for the specific language governing permissions
11*7836SJohn.Forte@Sun.COM  * and limitations under the License.
12*7836SJohn.Forte@Sun.COM  *
13*7836SJohn.Forte@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
14*7836SJohn.Forte@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*7836SJohn.Forte@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
16*7836SJohn.Forte@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
17*7836SJohn.Forte@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
18*7836SJohn.Forte@Sun.COM  *
19*7836SJohn.Forte@Sun.COM  * CDDL HEADER END
20*7836SJohn.Forte@Sun.COM  */
21*7836SJohn.Forte@Sun.COM /*
22*7836SJohn.Forte@Sun.COM  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23*7836SJohn.Forte@Sun.COM  * Use is subject to license terms.
24*7836SJohn.Forte@Sun.COM  */
25*7836SJohn.Forte@Sun.COM 
26*7836SJohn.Forte@Sun.COM #ifndef	_EXCEPTIONS_H
27*7836SJohn.Forte@Sun.COM #define	_EXCEPTIONS_H
28*7836SJohn.Forte@Sun.COM 
29*7836SJohn.Forte@Sun.COM 
30*7836SJohn.Forte@Sun.COM 
31*7836SJohn.Forte@Sun.COM #include <hbaapi.h>
32*7836SJohn.Forte@Sun.COM #include "Handle.h"
33*7836SJohn.Forte@Sun.COM #include "HBAPort.h"
34*7836SJohn.Forte@Sun.COM #include "Trace.h"
35*7836SJohn.Forte@Sun.COM #include <string>
36*7836SJohn.Forte@Sun.COM 
37*7836SJohn.Forte@Sun.COM /**
38*7836SJohn.Forte@Sun.COM  * @memo	    Superclass for all Exception we'll throw.
39*7836SJohn.Forte@Sun.COM  *
40*7836SJohn.Forte@Sun.COM  * @doc		    To ensure
41*7836SJohn.Forte@Sun.COM  * no uncaught exceptions squeeze through, all exceptions
42*7836SJohn.Forte@Sun.COM  * will map to some HBA_STATUS error code so we can easily
43*7836SJohn.Forte@Sun.COM  * handle them in catch blocks in our external API.
44*7836SJohn.Forte@Sun.COM  */
45*7836SJohn.Forte@Sun.COM class HBAException {
46*7836SJohn.Forte@Sun.COM public:
HBAException(HBA_STATUS err)47*7836SJohn.Forte@Sun.COM     HBAException(HBA_STATUS err) : errorCode(err) {
48*7836SJohn.Forte@Sun.COM 	Trace log("HBAException");
49*7836SJohn.Forte@Sun.COM 	log.debug("Error code: %d", err);
50*7836SJohn.Forte@Sun.COM 	log.stackTrace();
51*7836SJohn.Forte@Sun.COM     }
getErrorCode()52*7836SJohn.Forte@Sun.COM     HBA_STATUS getErrorCode() { return errorCode; }
53*7836SJohn.Forte@Sun.COM private:
54*7836SJohn.Forte@Sun.COM     HBA_STATUS errorCode;
55*7836SJohn.Forte@Sun.COM };
56*7836SJohn.Forte@Sun.COM 
57*7836SJohn.Forte@Sun.COM 
58*7836SJohn.Forte@Sun.COM /**
59*7836SJohn.Forte@Sun.COM  * @memo	    Represents HBA API "Not Supported" error
60*7836SJohn.Forte@Sun.COM  */
61*7836SJohn.Forte@Sun.COM class NotSupportedException : public HBAException {
62*7836SJohn.Forte@Sun.COM public:
NotSupportedException()63*7836SJohn.Forte@Sun.COM     NotSupportedException() : HBAException(HBA_STATUS_ERROR_NOT_SUPPORTED) { }
64*7836SJohn.Forte@Sun.COM };
65*7836SJohn.Forte@Sun.COM 
66*7836SJohn.Forte@Sun.COM /**
67*7836SJohn.Forte@Sun.COM  * @memo	    Represents HBA API "Invalid Handle" error
68*7836SJohn.Forte@Sun.COM  */
69*7836SJohn.Forte@Sun.COM class InvalidHandleException : public HBAException {
70*7836SJohn.Forte@Sun.COM public:
InvalidHandleException()71*7836SJohn.Forte@Sun.COM     InvalidHandleException() : HBAException(HBA_STATUS_ERROR_INVALID_HANDLE) { }
72*7836SJohn.Forte@Sun.COM };
73*7836SJohn.Forte@Sun.COM 
74*7836SJohn.Forte@Sun.COM /**
75*7836SJohn.Forte@Sun.COM  * @memo	    Represents HBA API "Bad Argument" error
76*7836SJohn.Forte@Sun.COM 
77*7836SJohn.Forte@Sun.COM  */
78*7836SJohn.Forte@Sun.COM class BadArgumentException : public HBAException {
79*7836SJohn.Forte@Sun.COM public:
BadArgumentException()80*7836SJohn.Forte@Sun.COM     BadArgumentException() : HBAException(HBA_STATUS_ERROR_ARG) { }
81*7836SJohn.Forte@Sun.COM };
82*7836SJohn.Forte@Sun.COM 
83*7836SJohn.Forte@Sun.COM /**
84*7836SJohn.Forte@Sun.COM  * @memo	    Represents HBA API "Illegal WWN" error
85*7836SJohn.Forte@Sun.COM  */
86*7836SJohn.Forte@Sun.COM class IllegalWWNException : public HBAException {
87*7836SJohn.Forte@Sun.COM public:
IllegalWWNException()88*7836SJohn.Forte@Sun.COM     IllegalWWNException() : HBAException(HBA_STATUS_ERROR_ILLEGAL_WWN) { }
89*7836SJohn.Forte@Sun.COM };
90*7836SJohn.Forte@Sun.COM 
91*7836SJohn.Forte@Sun.COM /**
92*7836SJohn.Forte@Sun.COM  * @memo	    Represents HBA API "Illegal Index" error
93*7836SJohn.Forte@Sun.COM  */
94*7836SJohn.Forte@Sun.COM class IllegalIndexException : public HBAException {
95*7836SJohn.Forte@Sun.COM public:
IllegalIndexException()96*7836SJohn.Forte@Sun.COM     IllegalIndexException() : HBAException(HBA_STATUS_ERROR_ILLEGAL_INDEX) { }
97*7836SJohn.Forte@Sun.COM };
98*7836SJohn.Forte@Sun.COM 
99*7836SJohn.Forte@Sun.COM /**
100*7836SJohn.Forte@Sun.COM  * @memo	    Represents HBA API "More Data" error
101*7836SJohn.Forte@Sun.COM  */
102*7836SJohn.Forte@Sun.COM class MoreDataException : public HBAException {
103*7836SJohn.Forte@Sun.COM public:
MoreDataException()104*7836SJohn.Forte@Sun.COM     MoreDataException() : HBAException(HBA_STATUS_ERROR_MORE_DATA) { }
105*7836SJohn.Forte@Sun.COM };
106*7836SJohn.Forte@Sun.COM 
107*7836SJohn.Forte@Sun.COM /**
108*7836SJohn.Forte@Sun.COM  * @memo	    Represents HBA API "Stale Data" error
109*7836SJohn.Forte@Sun.COM  */
110*7836SJohn.Forte@Sun.COM class StaleDataException : public HBAException {
111*7836SJohn.Forte@Sun.COM public:
StaleDataException()112*7836SJohn.Forte@Sun.COM     StaleDataException() : HBAException(HBA_STATUS_ERROR_STALE_DATA) { }
113*7836SJohn.Forte@Sun.COM };
114*7836SJohn.Forte@Sun.COM 
115*7836SJohn.Forte@Sun.COM /**
116*7836SJohn.Forte@Sun.COM  * @memo	    Represents HBA API "SCSI Check Condition" error
117*7836SJohn.Forte@Sun.COM  */
118*7836SJohn.Forte@Sun.COM class CheckConditionException : public HBAException {
119*7836SJohn.Forte@Sun.COM public:
CheckConditionException()120*7836SJohn.Forte@Sun.COM     CheckConditionException() : HBAException(HBA_STATUS_SCSI_CHECK_CONDITION) { }
121*7836SJohn.Forte@Sun.COM };
122*7836SJohn.Forte@Sun.COM 
123*7836SJohn.Forte@Sun.COM /**
124*7836SJohn.Forte@Sun.COM  * @memo	    Represents HBA API "Busy" error
125*7836SJohn.Forte@Sun.COM  */
126*7836SJohn.Forte@Sun.COM class BusyException : public HBAException {
127*7836SJohn.Forte@Sun.COM public:
BusyException()128*7836SJohn.Forte@Sun.COM     BusyException() : HBAException(HBA_STATUS_ERROR_BUSY) { }
129*7836SJohn.Forte@Sun.COM };
130*7836SJohn.Forte@Sun.COM 
131*7836SJohn.Forte@Sun.COM /**
132*7836SJohn.Forte@Sun.COM  * @memo	    Represents HBA API "Try Again" error
133*7836SJohn.Forte@Sun.COM  */
134*7836SJohn.Forte@Sun.COM class TryAgainException : public HBAException {
135*7836SJohn.Forte@Sun.COM public:
TryAgainException()136*7836SJohn.Forte@Sun.COM     TryAgainException() : HBAException(HBA_STATUS_ERROR_TRY_AGAIN) { }
137*7836SJohn.Forte@Sun.COM };
138*7836SJohn.Forte@Sun.COM 
139*7836SJohn.Forte@Sun.COM /**
140*7836SJohn.Forte@Sun.COM  * @memo	    Represents HBA API "Unavailable" error
141*7836SJohn.Forte@Sun.COM  */
142*7836SJohn.Forte@Sun.COM class UnavailableException : public HBAException {
143*7836SJohn.Forte@Sun.COM public:
UnavailableException()144*7836SJohn.Forte@Sun.COM     UnavailableException() : HBAException(HBA_STATUS_ERROR_UNAVAILABLE) { }
145*7836SJohn.Forte@Sun.COM };
146*7836SJohn.Forte@Sun.COM 
147*7836SJohn.Forte@Sun.COM /**
148*7836SJohn.Forte@Sun.COM  * @memo	    Represents HBA API "ELS Rejection" error
149*7836SJohn.Forte@Sun.COM  */
150*7836SJohn.Forte@Sun.COM class ELSRejectException : public HBAException {
151*7836SJohn.Forte@Sun.COM public:
ELSRejectException()152*7836SJohn.Forte@Sun.COM     ELSRejectException() : HBAException(HBA_STATUS_ERROR_ELS_REJECT) { }
153*7836SJohn.Forte@Sun.COM };
154*7836SJohn.Forte@Sun.COM 
155*7836SJohn.Forte@Sun.COM /**
156*7836SJohn.Forte@Sun.COM  * @memo	    Represents HBA API "Invalid Logical Unit Number" error
157*7836SJohn.Forte@Sun.COM  */
158*7836SJohn.Forte@Sun.COM class InvalidLUNException : public HBAException {
159*7836SJohn.Forte@Sun.COM public:
InvalidLUNException()160*7836SJohn.Forte@Sun.COM     InvalidLUNException() : HBAException(HBA_STATUS_ERROR_INVALID_LUN) { }
161*7836SJohn.Forte@Sun.COM };
162*7836SJohn.Forte@Sun.COM 
163*7836SJohn.Forte@Sun.COM /**
164*7836SJohn.Forte@Sun.COM  * @memo	    Represents HBA API "Incompatible" error
165*7836SJohn.Forte@Sun.COM  */
166*7836SJohn.Forte@Sun.COM class IncompatibleException : public HBAException {
167*7836SJohn.Forte@Sun.COM public:
IncompatibleException()168*7836SJohn.Forte@Sun.COM     IncompatibleException() : HBAException(HBA_STATUS_ERROR_INCOMPATIBLE) { }
169*7836SJohn.Forte@Sun.COM };
170*7836SJohn.Forte@Sun.COM 
171*7836SJohn.Forte@Sun.COM /**
172*7836SJohn.Forte@Sun.COM  * @memo	    Represents HBA API "Ambiguous WWN" error
173*7836SJohn.Forte@Sun.COM  */
174*7836SJohn.Forte@Sun.COM class AmbiguousWWNException : public HBAException {
175*7836SJohn.Forte@Sun.COM public:
AmbiguousWWNException()176*7836SJohn.Forte@Sun.COM     AmbiguousWWNException() : HBAException(HBA_STATUS_ERROR_AMBIGUOUS_WWN) { }
177*7836SJohn.Forte@Sun.COM };
178*7836SJohn.Forte@Sun.COM 
179*7836SJohn.Forte@Sun.COM /**
180*7836SJohn.Forte@Sun.COM  * @memo	    Represents HBA API "Not a Target" error
181*7836SJohn.Forte@Sun.COM  */
182*7836SJohn.Forte@Sun.COM class NotATargetException : public HBAException {
183*7836SJohn.Forte@Sun.COM public:
NotATargetException()184*7836SJohn.Forte@Sun.COM     NotATargetException() : HBAException(HBA_STATUS_ERROR_NOT_A_TARGET) { }
185*7836SJohn.Forte@Sun.COM };
186*7836SJohn.Forte@Sun.COM 
187*7836SJohn.Forte@Sun.COM /**
188*7836SJohn.Forte@Sun.COM  * @memo	    Represents HBA API "Unsupported FC4 type" error
189*7836SJohn.Forte@Sun.COM  */
190*7836SJohn.Forte@Sun.COM class UnsupportedFC4Exception : public HBAException {
191*7836SJohn.Forte@Sun.COM public:
UnsupportedFC4Exception()192*7836SJohn.Forte@Sun.COM     UnsupportedFC4Exception() : HBAException(HBA_STATUS_ERROR_UNSUPPORTED_FC4) { }
193*7836SJohn.Forte@Sun.COM };
194*7836SJohn.Forte@Sun.COM 
195*7836SJohn.Forte@Sun.COM /**
196*7836SJohn.Forte@Sun.COM  * @memo	    Represents HBA API "Incapable" error
197*7836SJohn.Forte@Sun.COM  */
198*7836SJohn.Forte@Sun.COM class IncapableException : public HBAException {
199*7836SJohn.Forte@Sun.COM public:
IncapableException()200*7836SJohn.Forte@Sun.COM     IncapableException() : HBAException(HBA_STATUS_ERROR_INCAPABLE) { }
201*7836SJohn.Forte@Sun.COM };
202*7836SJohn.Forte@Sun.COM 
203*7836SJohn.Forte@Sun.COM /**
204*7836SJohn.Forte@Sun.COM  * @memo	    Encapsulate I/O error scenarios.
205*7836SJohn.Forte@Sun.COM  *
206*7836SJohn.Forte@Sun.COM  * @doc		    If logging is enabled, this will
207*7836SJohn.Forte@Sun.COM  * automatically log the failure with as much detail as possible.
208*7836SJohn.Forte@Sun.COM  */
209*7836SJohn.Forte@Sun.COM class IOError : public HBAException {
210*7836SJohn.Forte@Sun.COM public:
211*7836SJohn.Forte@Sun.COM     IOError(std::string message);
212*7836SJohn.Forte@Sun.COM     IOError(Handle *handle);
213*7836SJohn.Forte@Sun.COM     IOError(HBAPort *port);
214*7836SJohn.Forte@Sun.COM     IOError(HBAPort *port, uint64_t target);
215*7836SJohn.Forte@Sun.COM     IOError(HBAPort *port, uint64_t target, uint64_t lun);
216*7836SJohn.Forte@Sun.COM };
217*7836SJohn.Forte@Sun.COM 
218*7836SJohn.Forte@Sun.COM /**
219*7836SJohn.Forte@Sun.COM  * @memo	    Generic error of unknown type
220*7836SJohn.Forte@Sun.COM  *
221*7836SJohn.Forte@Sun.COM  * @doc
222*7836SJohn.Forte@Sun.COM  * Grab bag for something catastrophic occuring in the internal
223*7836SJohn.Forte@Sun.COM  * logic of the VSL.  Hopefully, this should never ever happen.
224*7836SJohn.Forte@Sun.COM  */
225*7836SJohn.Forte@Sun.COM class InternalError : public HBAException {
226*7836SJohn.Forte@Sun.COM public:
227*7836SJohn.Forte@Sun.COM     InternalError();
228*7836SJohn.Forte@Sun.COM     InternalError(std::string message);
229*7836SJohn.Forte@Sun.COM };
230*7836SJohn.Forte@Sun.COM 
231*7836SJohn.Forte@Sun.COM #endif /* _EXCEPTIONS_H */
232