8#ifndef CPIXIESHIMGUARD_H
9#define CPIXIESHIMGUARD_H
30template <
typename T,
typename R,
typename Fn>
31R
shimGuard(T *utils,
const char *where, R fallback, Fn fn) {
33 utils->SetLastErrorMessage(
"");
35 }
catch (
const std::exception &e) {
36 utils->SetLastErrorMessage(e.what());
37 std::cerr << where <<
" unexpected std::exception: " << e.what()
41 utils->SetLastErrorMessage(
"unknown exception");
42 std::cerr << where <<
" unknown exception" << std::endl;
53template <
typename T,
typename Fn>
56 utils->SetLastErrorMessage(
"");
58 }
catch (
const std::exception &e) {
59 utils->SetLastErrorMessage(e.what());
60 std::cerr << where <<
" unexpected std::exception: " << e.what()
63 utils->SetLastErrorMessage(
"unknown exception");
64 std::cerr << where <<
" unknown exception" << std::endl;
79 }
catch (
const std::exception &e) {
81 <<
" construction failed: unhandled std::exception: " << e.what()
85 std::cerr << where <<
" construction failed: unknown exception"
R shimGuard(T *utils, const char *where, R fallback, Fn fn)
Run fn() inside the boundary net; return fallback on any exception. T must provide SetLastErrorMessag...
Definition: CPixieShimGuard.h:31
void shimGuardVoid(T *utils, const char *where, Fn fn)
Same net for void shims.
Definition: CPixieShimGuard.h:54
constexpr int SHIM_UNEXPECTED_ERROR
Definition: CPixieShimGuard.h:19
auto shimGuardNew(const char *where, Fn fn) -> decltype(fn())
Net for the constructors: no object exists yet to store a message in, so log and return nullptr (the ...
Definition: CPixieShimGuard.h:76