/home/aconway/svn/qpid/cpp/src/qpid/QpidError.h

00001 #ifndef __QpidError__
00002 #define __QpidError__
00003 /*
00004  *
00005  * Licensed to the Apache Software Foundation (ASF) under one
00006  * or more contributor license agreements.  See the NOTICE file
00007  * distributed with this work for additional information
00008  * regarding copyright ownership.  The ASF licenses this file
00009  * to you under the Apache License, Version 2.0 (the
00010  * "License"); you may not use this file except in compliance
00011  * with the License.  You may obtain a copy of the License at
00012  * 
00013  *   http://www.apache.org/licenses/LICENSE-2.0
00014  * 
00015  * Unless required by applicable law or agreed to in writing,
00016  * software distributed under the License is distributed on an
00017  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
00018  * KIND, either express or implied.  See the License for the
00019  * specific language governing permissions and limitations
00020  * under the License.
00021  *
00022  */
00023 #include <string>
00024 #include <memory>
00025 #include <ostream>
00026 
00027 #include "Exception.h"
00028 
00029 namespace qpid {
00030 
00031 struct SrcLine {
00032   public:
00033     SrcLine(const std::string& file_="", int line_=0) :
00034         file(file_), line(line_) {}
00035 
00036     std::string file;
00037     int line;
00038 };
00039     
00040 class QpidError : public Exception
00041 {
00042   public:
00043     const int code;
00044     SrcLine loc;
00045     std::string msg;
00046 
00047     QpidError();
00048 
00049     template <class T>
00050     QpidError(int code_, const T& msg_, const SrcLine& loc_) throw()
00051         : code(code_), loc(loc_), msg(boost::lexical_cast<std::string>(msg_))
00052     { init(); }
00053         
00054     ~QpidError() throw();
00055     Exception* clone() const throw();
00056     void throwSelf() const;
00057 
00058   private:
00059     
00060     void init();
00061 };
00062 
00063 
00064 } // namespace qpid
00065 
00066 #define SRCLINE ::qpid::SrcLine(__FILE__, __LINE__)
00067 
00068 #define QPID_ERROR(CODE, MESSAGE) ::qpid::QpidError((CODE), (MESSAGE), SRCLINE)
00069 
00070 #define THROW_QPID_ERROR(CODE, MESSAGE) throw QPID_ERROR(CODE,MESSAGE)
00071 
00072 const int PROTOCOL_ERROR = 10000;
00073 const int APR_ERROR = 20000;
00074 const int FRAMING_ERROR = 30000;
00075 const int CLIENT_ERROR = 40000;
00076 const int INTERNAL_ERROR = 50000;
00077 
00078 #endif

Generated on Tue Apr 17 14:22:03 2007 for Qpid by  doxygen 1.4.7