You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the moment, server.js has several try/catch blocks that do "error filtering":
try{constdata=awaitgetData()ctx.body=data}catch(err){if(err.message.startsWith('invalid tree ref')){ctx.throw(404,'unknown ref')}else{throwerr}}
There's some redundancy there and it decreases readability. There has to be a better way. I think it is to have lib/GitSheets.js throw custom errors, e.g. NotFoundError, and have server.js map these to status codes in a single place (the error handler function).
That still leaves the errors that originate beneath lib/GitSheets.js (from hologit, gitsheets, or git). I expect we'll still have to do some string matching on that, but it can be at the lib level rather than the server level. So we'll essentially translate invalid tree ref to NotFoundError, and the server and CLI just need to decide what to do with a NotFoundError.
We can use create-error for custom errors or probably just do it manually.
The text was updated successfully, but these errors were encountered:
At the moment,
server.js
has several try/catch blocks that do "error filtering":There's some redundancy there and it decreases readability. There has to be a better way. I think it is to have
lib/GitSheets.js
throw custom errors, e.g.NotFoundError
, and haveserver.js
map these to status codes in a single place (the error handler function).That still leaves the errors that originate beneath
lib/GitSheets.js
(from hologit, gitsheets, or git). I expect we'll still have to do some string matching on that, but it can be at the lib level rather than the server level. So we'll essentially translateinvalid tree ref
toNotFoundError
, and the server and CLI just need to decide what to do with aNotFoundError
.We can use create-error for custom errors or probably just do it manually.
The text was updated successfully, but these errors were encountered: