diff options
author | sterni <sternenseemann@systemli.org> | 2021-04-04T23·53+0200 |
---|---|---|
committer | sterni <sternenseemann@systemli.org> | 2021-04-05T10·54+0000 |
commit | 1c0f89f4cadba4957e95fc80b25b1b8b6dd1a3b3 (patch) | |
tree | 3c0e209f13a3d8b3fb19c9bacde5b617458ae2d4 /web/bubblegum/examples | |
parent | cbd6f5bbae95c26b1e67993ac609e83fa4b117fb (diff) |
feat(web/bubblegum): report some errors to the user via HTTP r/2438
We can actually catch some errors that may be generated in bubblegum applications where we can report them to the user in a way that doesn't require curl -vv: * Type errors in the status argument: By removing yants completely we not only (presumably) gain some performance, but also the ability to return an internal server error on an unexpected type instead of throwing. * User generated evaluation errors: by using builtins.tryEval we can catch throws and asserts the user inserted when generating the body and report to the user that something went wrong. To do: also support for the headers. Change-Id: I8363b9825c6c730e624eb8016a5482d63cbc1890 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2849 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
Diffstat (limited to 'web/bubblegum/examples')
-rw-r--r-- | web/bubblegum/examples/hello.nix | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/web/bubblegum/examples/hello.nix b/web/bubblegum/examples/hello.nix index 881426bd1212..f6706eb2177e 100644 --- a/web/bubblegum/examples/hello.nix +++ b/web/bubblegum/examples/hello.nix @@ -33,6 +33,18 @@ let No coffee, I'm afraid ''; }; + "/type-error" = { + status = 666; + title = "bad usage"; + content = '' + Never gonna see this. + ''; + }; + "/eval-error" = { + status = "OK"; + title = "evaluation error"; + content = builtins.throw "lol"; + }; }; notFound = { |