8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / lib / sun_fc / common / Exceptions.h
blob61ecd1bbe1f827e9bae6b8eac9ddfff3a2c326e2
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #ifndef _EXCEPTIONS_H
27 #define _EXCEPTIONS_H
31 #include <hbaapi.h>
32 #include "Handle.h"
33 #include "HBAPort.h"
34 #include "Trace.h"
35 #include <string>
37 /**
38 * @memo Superclass for all Exception we'll throw.
40 * @doc To ensure
41 * no uncaught exceptions squeeze through, all exceptions
42 * will map to some HBA_STATUS error code so we can easily
43 * handle them in catch blocks in our external API.
45 class HBAException {
46 public:
47 HBAException(HBA_STATUS err) : errorCode(err) {
48 Trace log("HBAException");
49 log.debug("Error code: %d", err);
50 log.stackTrace();
52 HBA_STATUS getErrorCode() { return errorCode; }
53 private:
54 HBA_STATUS errorCode;
58 /**
59 * @memo Represents HBA API "Not Supported" error
61 class NotSupportedException : public HBAException {
62 public:
63 NotSupportedException() : HBAException(HBA_STATUS_ERROR_NOT_SUPPORTED) { }
66 /**
67 * @memo Represents HBA API "Invalid Handle" error
69 class InvalidHandleException : public HBAException {
70 public:
71 InvalidHandleException() : HBAException(HBA_STATUS_ERROR_INVALID_HANDLE) { }
74 /**
75 * @memo Represents HBA API "Bad Argument" error
78 class BadArgumentException : public HBAException {
79 public:
80 BadArgumentException() : HBAException(HBA_STATUS_ERROR_ARG) { }
83 /**
84 * @memo Represents HBA API "Illegal WWN" error
86 class IllegalWWNException : public HBAException {
87 public:
88 IllegalWWNException() : HBAException(HBA_STATUS_ERROR_ILLEGAL_WWN) { }
91 /**
92 * @memo Represents HBA API "Illegal Index" error
94 class IllegalIndexException : public HBAException {
95 public:
96 IllegalIndexException() : HBAException(HBA_STATUS_ERROR_ILLEGAL_INDEX) { }
99 /**
100 * @memo Represents HBA API "More Data" error
102 class MoreDataException : public HBAException {
103 public:
104 MoreDataException() : HBAException(HBA_STATUS_ERROR_MORE_DATA) { }
108 * @memo Represents HBA API "Stale Data" error
110 class StaleDataException : public HBAException {
111 public:
112 StaleDataException() : HBAException(HBA_STATUS_ERROR_STALE_DATA) { }
116 * @memo Represents HBA API "SCSI Check Condition" error
118 class CheckConditionException : public HBAException {
119 public:
120 CheckConditionException() : HBAException(HBA_STATUS_SCSI_CHECK_CONDITION) { }
124 * @memo Represents HBA API "Busy" error
126 class BusyException : public HBAException {
127 public:
128 BusyException() : HBAException(HBA_STATUS_ERROR_BUSY) { }
132 * @memo Represents HBA API "Try Again" error
134 class TryAgainException : public HBAException {
135 public:
136 TryAgainException() : HBAException(HBA_STATUS_ERROR_TRY_AGAIN) { }
140 * @memo Represents HBA API "Unavailable" error
142 class UnavailableException : public HBAException {
143 public:
144 UnavailableException() : HBAException(HBA_STATUS_ERROR_UNAVAILABLE) { }
148 * @memo Represents HBA API "ELS Rejection" error
150 class ELSRejectException : public HBAException {
151 public:
152 ELSRejectException() : HBAException(HBA_STATUS_ERROR_ELS_REJECT) { }
156 * @memo Represents HBA API "Invalid Logical Unit Number" error
158 class InvalidLUNException : public HBAException {
159 public:
160 InvalidLUNException() : HBAException(HBA_STATUS_ERROR_INVALID_LUN) { }
164 * @memo Represents HBA API "Incompatible" error
166 class IncompatibleException : public HBAException {
167 public:
168 IncompatibleException() : HBAException(HBA_STATUS_ERROR_INCOMPATIBLE) { }
172 * @memo Represents HBA API "Ambiguous WWN" error
174 class AmbiguousWWNException : public HBAException {
175 public:
176 AmbiguousWWNException() : HBAException(HBA_STATUS_ERROR_AMBIGUOUS_WWN) { }
180 * @memo Represents HBA API "Not a Target" error
182 class NotATargetException : public HBAException {
183 public:
184 NotATargetException() : HBAException(HBA_STATUS_ERROR_NOT_A_TARGET) { }
188 * @memo Represents HBA API "Unsupported FC4 type" error
190 class UnsupportedFC4Exception : public HBAException {
191 public:
192 UnsupportedFC4Exception() : HBAException(HBA_STATUS_ERROR_UNSUPPORTED_FC4) { }
196 * @memo Represents HBA API "Incapable" error
198 class IncapableException : public HBAException {
199 public:
200 IncapableException() : HBAException(HBA_STATUS_ERROR_INCAPABLE) { }
204 * @memo Encapsulate I/O error scenarios.
206 * @doc If logging is enabled, this will
207 * automatically log the failure with as much detail as possible.
209 class IOError : public HBAException {
210 public:
211 IOError(std::string message);
212 IOError(Handle *handle);
213 IOError(HBAPort *port);
214 IOError(HBAPort *port, uint64_t target);
215 IOError(HBAPort *port, uint64_t target, uint64_t lun);
219 * @memo Generic error of unknown type
221 * @doc
222 * Grab bag for something catastrophic occuring in the internal
223 * logic of the VSL. Hopefully, this should never ever happen.
225 class InternalError : public HBAException {
226 public:
227 InternalError();
228 InternalError(std::string message);
231 #endif /* _EXCEPTIONS_H */