MCPcopy Create free account
hub / github.com/CoolProp/CoolProp / HandleException

Function HandleException

src/CoolPropLib.cpp:33–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31 }
32}
33void HandleException(long* errcode, char* message_buffer, const long buffer_length) {
34 try {
35 throw; // Rethrow the error, and here we handle the error
36 } catch (CoolProp::HandleError& e) {
37 std::string errmsg = std::string("HandleError: ") + e.what();
38 if (errmsg.size() < static_cast<std::size_t>(buffer_length)) {
39 *errcode = 1;
40 std::memcpy(message_buffer, errmsg.c_str(), errmsg.size() + 1); // guarded above: size + null fits
41 } else {
42 *errcode = 2;
43 }
44 } catch (CoolProp::CoolPropBaseError& e) {
45 std::string errmsg = std::string("Error: ") + e.what();
46 if (errmsg.size() < static_cast<std::size_t>(buffer_length)) {
47 *errcode = 1;
48 std::memcpy(message_buffer, errmsg.c_str(), errmsg.size() + 1); // guarded above: size + null fits
49 } else {
50 *errcode = 2;
51 }
52 } catch (...) {
53 *errcode = 3;
54 }
55}
56
57// FP-exception handling at the C-interface boundary lives in CoolProp/FPUGuard.h
58// (CoolProp::fpu_guard). It masks FP exceptions on entry so trapping hosts

Calls 3

whatMethod · 0.80
stringClass · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected