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