22#ifndef DXCPP_EXCEPTIONS_H
23#define DXCPP_EXCEPTIONS_H
27#include <boost/lexical_cast.hpp>
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";
43 class DXError:
public std::exception {
47 mutable std::string error_msg;
49 DXError():
msg(
"Unknown error occured while using dxcpp.") { }
51 virtual const char* what()
const throw() {
52 error_msg =
type +
": '" +
msg +
"'";
53 return (
const char*)
msg.c_str();
56 virtual ~DXError() throw() { }
64 class DXAPIError:
public DXError {
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();
76 virtual ~DXAPIError() throw() { }
79 class DXConnectionError:
public DXError {
83 DXConnectionError(
const std::string
msg,
int curl_code,
const std::string &
type=DXErrorTypes::DXCONNECTION_ERROR):
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();
91 virtual ~DXConnectionError() throw() { }
95 class DXFileError:
public DXError {
97 DXFileError(): DXError(
"Unknown error occured while using DXFile class.") { }
98 DXFileError(
const std::string &
msg,
const std::string &
type=DXErrorTypes::DXFILE_ERROR): DXError(
msg,
type) { }
100 virtual ~DXFileError()
throw() { }
104 class DXAppError:
public DXError {
106 DXAppError(): DXError(
"Unknown error occured while using DXApp class.") { }
107 DXAppError(
const std::string &
msg,
const std::string &
type=DXErrorTypes::DXAPP_ERROR): DXError(
msg,
type) { }
109 virtual ~DXAppError()
throw() { }
113 class DXJobError:
public DXError {
115 DXJobError(): DXError(
"Unknown error occured while using DXJob class.") { }
116 DXJobError(
const std::string &
msg,
const std::string &
type=DXErrorTypes::DXJOB_ERROR): DXError(
msg,
type) { }
118 virtual ~DXJobError()
throw() { }
125 class DXNotImplementedError:
public DXError {
127 DXNotImplementedError(): DXError(
"Not yet implemented.") { }
128 DXNotImplementedError(
const std::string &
msg,
const std::string &
type=DXErrorTypes::DXNOT_IMPLEMENTED_ERROR): DXError(
msg,
type) { }
130 virtual ~DXNotImplementedError()
throw() { }
int resp_code
HTTP status code returned by the apiserver.
Definition exceptions.h:66
int curl_code
Curl code (returned by libcurl).
Definition exceptions.h:81
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
std::string msg
The actual error message.
Definition exceptions.h:45
Definition exceptions.h:33
An executable object that can be published for others to discover.
Definition api.cc:7