joaotavora / snooze

Common Lisp RESTful web development
207 stars 23 forks source link

Errors should be errors #21

Closed ruricolist closed 4 years ago

ruricolist commented 4 years ago

The conditions no-such-resource, no-such-route, and invalid-resource-arguments are signaled with error, so they invoke the debugger, but are not subtypes of error (or even serious-condition), so they are not caught by handlers.

From the production standpoint, this is bad. If the debugger is disabled, this means the app dies on every 404. If the debugger is not disabled, it hangs on every 404.

Of course, one could explicitly handle http-condition signals, but that isn't documented anywhere and I think it would be much less surprising if all the error conditions were actually of type error.

ruricolist commented 4 years ago

Never mind, I only thought I had read the docs.

joaotavora commented 4 years ago

:-)

Actually, I don't remember anymore what the doc states anymore on this. But your "errors should be errors" sounds sensible. I'll review myself.

joaotavora commented 4 years ago

Yep it seems you need to use Snooze's API for this, explain-condition. The reason they aren't error is, if I remember correctly, a conscious design decision: "they are part of everyday HTTP life" I wrote. If they were errors, they would be caught by the error handlers designed for Lisp errors, and I don't think we want that. The reason I signal them with error is, I believe, only a shortcut to a function that signal s and then invokes the debugger if no handling happens in the meantime.

I think we want that: and there is indeed some default handling that checks the values of some variables.

This has been tested very summarily, Paul, and I'd love to know if this scheme is working out for you, or if you think it could be more flexible.