Просмотр исходного кода

Added Exception ctor which takes both errNum and errorCode.

Also added DlAbortEx ctor which has same signature with new Exception
dtor.  Added DL_ABORT_EX3 macro to use added ctor.
Tatsuhiro Tsujikawa 15 лет назад
Родитель
Сommit
ce6eb592da
6 измененных файлов с 44 добавлено и 4 удалено
  1. 9 3
      src/DlAbortEx.cc
  2. 6 1
      src/DlAbortEx.h
  3. 13 0
      src/Exception.cc
  4. 3 0
      src/Exception.h
  5. 9 0
      src/RecoverableException.cc
  6. 4 0
      src/RecoverableException.h

+ 9 - 3
src/DlAbortEx.cc

@@ -49,12 +49,18 @@ DlAbortEx::DlAbortEx(const char* file, int line, const std::string& msg,
                      const Exception& cause):
   RecoverableException(file, line, msg, cause) {}
 
+DlAbortEx::DlAbortEx(const char* file, int line, const std::string& msg,
+                     error_code::Value code):
+  RecoverableException(file, line, msg, code) {}
+
 DlAbortEx::DlAbortEx
 (const char* file, int line, int errNum, const std::string& msg):
   RecoverableException(file, line, errNum, msg) {}
 
-DlAbortEx::DlAbortEx(const char* file, int line, const std::string& msg,
-                     error_code::Value code):
-  RecoverableException(file, line, msg, code) {}
+DlAbortEx::DlAbortEx
+(const char* file, int line, int errNum, const std::string& msg,
+ error_code::Value errorCode)
+  : RecoverableException(file, line, errNum, msg, errorCode)
+{}
 
 } // namespace aria2

+ 6 - 1
src/DlAbortEx.h

@@ -47,14 +47,19 @@ public:
   DlAbortEx(const char* file, int line, const std::string& msg,
             const Exception& cause);
 
+  DlAbortEx(const char* file, int line, const std::string& msg,
+            error_code::Value code);
+
   DlAbortEx(const char* file, int line, int errNum, const std::string& msg);
 
-  DlAbortEx(const char* file, int line, const std::string& msg,
+  DlAbortEx(const char* file, int line, int errNum, const std::string& msg,
             error_code::Value code);
 };
 
 #define DL_ABORT_EX(arg) DlAbortEx(__FILE__, __LINE__, arg)
 #define DL_ABORT_EX2(arg1, arg2) DlAbortEx(__FILE__, __LINE__, arg1, arg2)
+#define DL_ABORT_EX3(arg1, arg2, arg3)\
+  DlAbortEx(__FILE__, __LINE__, arg1, arg2, arg3)
 
 } // namespace aria2
 

+ 13 - 0
src/Exception.cc

@@ -86,6 +86,19 @@ Exception::Exception
     errorCode_(error_code::UNKNOWN_ERROR)
 {}
 
+Exception::Exception
+(const char* file,
+ int line,
+ int errNum,
+ const std::string& msg,
+ error_code::Value errorCode)
+  : file_(file),
+    line_(line),
+    errNum_(errNum),
+    msg_(msg),
+    errorCode_(errorCode)
+{}
+
 Exception::~Exception() throw() {}
 
 std::string Exception::stackTrace() const

+ 3 - 0
src/Exception.h

@@ -72,6 +72,9 @@ public:
 
   Exception(const char* file, int line, int errNum, const std::string& msg);
 
+  Exception(const char* file, int line, int errNum, const std::string& msg,
+            error_code::Value errorCode);
+
   virtual ~Exception() throw();
 
   virtual const char* what() const throw();

+ 9 - 0
src/RecoverableException.cc

@@ -64,4 +64,13 @@ RecoverableException::RecoverableException
   : Exception(file, line, errNum, msg)
 {}
 
+RecoverableException::RecoverableException
+(const char* file,
+ int line,
+ int errNum,
+ const std::string& msg,
+ error_code::Value errorCode)
+  : Exception(file, line, errNum, msg, errorCode)
+{}
+
 } // namespace aria2

+ 4 - 0
src/RecoverableException.h

@@ -52,6 +52,10 @@ public:
 
   RecoverableException
   (const char* file, int line, int errNum, const std::string& msg);
+
+  RecoverableException
+  (const char* file, int line, int errNum, const std::string& msg,
+   error_code::Value errorCode);
 };
 
 } // namespace aria2