00001 /* 00002 * Copyright 2005-2009 WSO2, Inc. http://wso2.com 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef WSFEXCEPTION_H 00018 #define WSFEXCEPTION_H 00019 00020 #include <WSFDefines.h> 00021 #include <iostream> 00022 #include <string> 00023 00031 namespace wso2wsf 00032 { 00046 class Exception 00047 { 00054 friend WSF_EXTERN std::ostream & WSF_CALL operator <<(std::ostream & str, Exception const & e); 00055 00062 friend WSF_EXTERN std::ostream & WSF_CALL operator <<(std::ostream & str, Exception const * e); 00063 00064 private: 00068 std::string _reason; 00069 00073 std::string _code; 00074 00075 public: 00079 virtual WSF_CALL ~Exception(); 00080 00085 virtual void WSF_CALL process() const = 0; 00086 00092 virtual WSF_CALL operator std::string() const; 00093 00098 std::string WSF_CALL getFaultReason(); 00103 std::string WSF_CALL getFaultCode(); 00104 00105 protected: 00110 WSF_CALL Exception(char const * reason); 00116 WSF_CALL Exception(char const *reason, char const *code); 00117 00118 }; 00121 inline std::ostream & WSF_CALL operator <<(std::ostream & str, Exception const & e) 00122 { 00123 return str << const_cast<Exception &>(e).operator std::string(); 00124 } 00125 00126 inline std::ostream & WSF_CALL operator <<(std::ostream & str, Exception const * e) 00127 { 00128 return str << const_cast<Exception *>(e)->operator std::string(); 00129 } 00130 } 00131 #endif // WSFEXCEPTION_H