2 * Copyright 2012-2013 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef MSG_EXCEPTION_H
18 #define MSG_EXCEPTION_H
20 /*==================================================================================================
22 ==================================================================================================*/
29 /*==================================================================================================
31 ==================================================================================================*/
32 #define THROW(errCode, debugFmt,...) \
34 char __debugBuf[256];\
35 snprintf(__debugBuf, 256, debugFmt, ##__VA_ARGS__);\
36 MsgException e(errCode, __debugBuf);\
37 MSG_FATAL("%s [%d]", e.what(), e.errorCode());\
42 /*==================================================================================================
44 ==================================================================================================*/
45 class MsgException : public runtime_error //public exception
48 MsgException(int errCode, const string& msg = "")
49 : runtime_error( errorStrings[errCode] + " : " + msg), eCode(errCode)
66 INCOMING_MSG_ERROR = 10,
70 SERVER_READY_ERROR = 13,
72 // dont erase NUM_ERRORS. place a new error code in ahead of NUM_ERRORS
76 int errorCode() { return eCode; }
79 static string errorStrings[NUM_ERRORS];
83 #endif //#ifndef __MSG_EXCEPTION_H__