22 #ifndef DXCPP_EXCEPTIONS_H 23 #define DXCPP_EXCEPTIONS_H 27 #include <boost/lexical_cast.hpp> 33 namespace DXErrorTypes {
34 static const std::string DEFAULT_ERROR =
"DXDefaultError";
35 static const std::string DXFILE_ERROR =
"DXFileError";
36 static const std::string DXAPP_ERROR =
"DXAppError";
37 static const std::string DXJOB_ERROR =
"DXJobError";
38 static const std::string DXCONNECTION_ERROR =
"DXConnectionError";
39 static const std::string DXNOT_IMPLEMENTED_ERROR =
"DXNotImplementedError";
47 mutable std::string error_msg;
49 DXError(): msg(
"Unknown error occured while using dxcpp.") { }
50 DXError(
const std::string &msg,
const std::string &type = DXErrorTypes::DEFAULT_ERROR): msg(msg), type(type) { }
51 virtual const char* what()
const throw() {
52 error_msg = type +
": '" + msg +
"'";
53 return (
const char*)msg.c_str();
68 DXAPIError(std::string msg, std::string type,
int resp_code) :
69 DXError(msg, type), resp_code(resp_code) {}
71 virtual const char* what()
const throw() {
72 error_msg = type +
": '" + msg +
"', Server returned HTTP code '" + boost::lexical_cast<std::string>(resp_code) +
"'";
73 return (
const char*)error_msg.c_str();
83 DXConnectionError(
const std::string msg,
int curl_code,
const std::string &type=DXErrorTypes::DXCONNECTION_ERROR):
84 DXError(msg, type), curl_code(curl_code) {}
86 virtual const char* what()
const throw() {
87 error_msg = type +
": '" + msg +
"', Curl error code = '" + boost::lexical_cast<std::string>(curl_code) +
"'";
88 return (
const char*)error_msg.c_str();
98 DXFileError(
const std::string &msg,
const std::string &type=DXErrorTypes::DXFILE_ERROR):
DXError(msg, type) { }
107 DXAppError(
const std::string &msg,
const std::string &type=DXErrorTypes::DXAPP_ERROR):
DXError(msg, type) { }
116 DXJobError(
const std::string &msg,
const std::string &type=DXErrorTypes::DXJOB_ERROR):
DXError(msg, type) { }
Represents errors relating to the DXJob class.
Definition: exceptions.h:113
std::string msg
The actual error message.
Definition: exceptions.h:45
int curl_code
Curl code (returned by libcurl)
Definition: exceptions.h:81
Definition: exceptions.h:125
Represents errors relating to the DXApp class.
Definition: exceptions.h:104
An executable object that can be published for others to discover.
Definition: api.cc:7
Definition: exceptions.h:64
Generic exception for the DNAnexus C++ library.
Definition: exceptions.h:43
std::string type
Type of the error message (can be a free-form string, but usually one of the static members from DXEr...
Definition: exceptions.h:46
Represents errors relating to the DXFile class.
Definition: exceptions.h:95
int resp_code
HTTP status code returned by the apiserver.
Definition: exceptions.h:66
Definition: exceptions.h:79