2286 |
// *************** Exception *************** |
// *************** Exception *************** |
2287 |
// * |
// * |
2288 |
|
|
2289 |
|
Exception::Exception() { |
2290 |
|
} |
2291 |
|
|
2292 |
|
Exception::Exception(String format, ...) { |
2293 |
|
va_list arg; |
2294 |
|
va_start(arg, format); |
2295 |
|
Message = assemble(format, arg); |
2296 |
|
va_end(arg); |
2297 |
|
} |
2298 |
|
|
2299 |
|
Exception::Exception(String format, va_list arg) { |
2300 |
|
Message = assemble(format, arg); |
2301 |
|
} |
2302 |
|
|
2303 |
/** @brief Print exception message to stdout. |
/** @brief Print exception message to stdout. |
2304 |
* |
* |
2305 |
* Prints the message of this Exception to the currently defined standard |
* Prints the message of this Exception to the currently defined standard |
2309 |
std::cout << "Serialization::Exception: " << Message << std::endl; |
std::cout << "Serialization::Exception: " << Message << std::endl; |
2310 |
} |
} |
2311 |
|
|
2312 |
|
String Exception::assemble(String format, va_list arg) { |
2313 |
|
char* buf = NULL; |
2314 |
|
vasprintf(&buf, format.c_str(), arg); |
2315 |
|
String s = buf; |
2316 |
|
free(buf); |
2317 |
|
return s; |
2318 |
|
} |
2319 |
|
|
2320 |
} // namespace Serialization |
} // namespace Serialization |