/home/aconway/svn/qpid/cpp/lib/common/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 #include <Exception.h>
00027 
00028 namespace qpid {
00029 
00030 struct SrcLine {
00031   public:
00032     SrcLine(const std::string& file_="", int line_=0) :
00033         file(file_), line(line_) {}
00034 
00035     std::string file;
00036     int line;
00037 };
00038     
00039 class QpidError : public Exception { 
00040   public:
00041     const int code;
00042     const std::string msg;
00043     const SrcLine location;
00044 
00045     QpidError();
00046     QpidError(int _code, const std::string& _msg, const SrcLine& _loc) throw();
00047     ~QpidError() throw();
00048     Exception* clone() const throw();
00049     void throwSelf() const;
00050 };
00051 
00052 
00053 } // namespace qpid
00054 
00055 #define SRCLINE ::qpid::SrcLine(__FILE__, __LINE__)
00056 
00057 #define QPID_ERROR(CODE, MESSAGE) ::qpid::QpidError((CODE), (MESSAGE), SRCLINE)
00058 
00059 #define THROW_QPID_ERROR(CODE, MESSAGE) throw QPID_ERROR(CODE,MESSAGE)
00060 
00061 const int PROTOCOL_ERROR = 10000;
00062 const int APR_ERROR = 20000;
00063 const int FRAMING_ERROR = 30000;
00064 const int CLIENT_ERROR = 40000;
00065 const int INTERNAL_ERROR = 50000;
00066 
00067 #endif

Generated on Thu Jan 25 11:48:13 2007 for Qpid by  doxygen 1.5.1