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