aboutsummaryrefslogtreecommitdiff
path: root/mod/mod-ci-github.cxx
diff options
context:
space:
mode:
authorFrancois Kritzinger <francois@codesynthesis.com>2024-02-23 14:06:38 +0200
committerFrancois Kritzinger <francois@codesynthesis.com>2024-04-24 15:14:54 +0200
commitd698e177032e403a89e58ff869496b62fb015ba4 (patch)
treeafc66d8ad5d196f0113a40382093e15b5ca8ef32 /mod/mod-ci-github.cxx
parentc80d712252f2bd9afce19b78375c1cd9ebc54cbd (diff)
Post-review changes
Diffstat (limited to 'mod/mod-ci-github.cxx')
-rw-r--r--mod/mod-ci-github.cxx32
1 files changed, 21 insertions, 11 deletions
diff --git a/mod/mod-ci-github.cxx b/mod/mod-ci-github.cxx
index 776c653..bccc1b9 100644
--- a/mod/mod-ci-github.cxx
+++ b/mod/mod-ci-github.cxx
@@ -360,6 +360,9 @@ namespace brep
// Note: re-open in/out so that they get automatically closed on
// exception.
//
+ // @@ TMP What if c.out.close() above throws io_error? Or are the
+ // odds just too low (given that it's empty) to matter?
+ //
ifdstream in (c.in.release (), fdstream_mode::skip);
// Read HTTP status code.
@@ -498,9 +501,12 @@ namespace brep
}
catch (const json::invalid_json_input& e)
{
- // @@ error (line/column/location)
+ string m ("malformed JSON in " + e.name + " request body");
+
+ error << m << " [line " << e.line << ", column " << e.column
+ << ", byte offset " << e.position << "]: " << e;
- throw invalid_request (400, "malformed JSON in request body");
+ throw invalid_request (400, move (m));
}
if (cs.action == "requested")
@@ -519,11 +525,12 @@ namespace brep
}
else
{
- // @@ error unknown action (we can't really ignore).
-
- // @@ Ignore empty response.
+ // Ignore unknown actions by sending a 200 response but also log an
+ // error.
+ //
+ error << "unknown action '" << cs.action << "' in check_suite webhook";
- throw invalid_request (400, "unsupported action: " + cs.action);
+ return true;
}
cout << "<check_suite webhook>" << endl << cs << endl;
@@ -572,15 +579,18 @@ namespace brep
//
if (sc != 201)
{
- // @@ fail (log status)
- //
- throw runtime_error ("error status code received from GitHub: " +
- to_string (sc));
+ fail << "unable to get installation access token: "
+ << "error HTTP response status " << sc
+ << " received from GitHub";
}
}
catch (const json::invalid_json_input& e)
{
- // @@ fail (line/column/location)
+ // Note: e.name is the GitHub API endpoint.
+ //
+ fail << "malformed JSON in response from " << e.name << " [line "
+ << e.line << ", column " << e.column << ", byte offset "
+ << e.position << "]: " << e;
}
catch (const system_error& e)
{