From 04fb982b5e78949ed7bb65ca36a89decf9ee284e Mon Sep 17 00:00:00 2001 From: Francois Kritzinger Date: Fri, 29 Nov 2024 07:39:08 +0200 Subject: build_built(): handle all exceptions --- mod/mod-ci-github.cxx | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'mod/mod-ci-github.cxx') diff --git a/mod/mod-ci-github.cxx b/mod/mod-ci-github.cxx index bfc6ebe..efe61e3 100644 --- a/mod/mod-ci-github.cxx +++ b/mod/mod-ci-github.cxx @@ -2263,6 +2263,7 @@ namespace brep build_built (const tenant_service& ts, const build& b, const diag_epilogue& log_writer) const noexcept + try { // NOTE: this function is noexcept and should not throw. @@ -2390,6 +2391,11 @@ namespace brep { using namespace web::xhtml; + // Note: let all serialization exceptions propagate. The XML + // serialization code can throw bad_alloc or xml::serialization in + // case of I/O failures, but we're serializing to a string stream so + // both exceptions are highly unlikely. + // ostringstream os; xml::serializer s (os, "check_run_summary"); @@ -2485,7 +2491,8 @@ namespace brep if (cr.node_id) { - // Update existing check run to built. + // Update existing check run to built. Let unlikely invalid_argument + // propagate. // if (gq_update_check_run (error, cr, @@ -2502,7 +2509,7 @@ namespace brep } else { - // Create new check run. + // Create new check run. Let unlikely invalid_argument propagate. // // Note that we don't have build hints so will be creating this check // run with the full build id as name. In the unlikely event that an @@ -2550,6 +2557,8 @@ namespace brep cr.node_id = *sd.conclusion_node_id; cr.name = conclusion_check_run_name; + // Let unlikely invalid_argument propagate. + // if (gq_update_check_run (error, cr, iat->token, @@ -2654,6 +2663,16 @@ namespace brep return sd.json (); }; } + catch (const std::exception& e) + { + NOTIFICATION_DIAG (log_writer); + + string bid (gh_check_run_name (b)); // Full build id. + + error << "check run " << bid << ": unhandled exception: " << e.what(); + + return nullptr; + } string ci_github:: details_url (const build& b) const -- cgit v1.1