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