-
Notifications
You must be signed in to change notification settings - Fork 3
Throughput RERUM Error Responses #102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
cubap
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'm okay with this. I didn't break it. I have some comments, but the most general one is that this is only TinyThings and not TinyPEN. If that is good with you - send it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically as middle ware I think the rerum response would come last but I see you
| rerum_err_text = undefined | ||
| } | ||
| if (rerum_err_text) error.message = rerum_err_text | ||
| else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You know I would have put a ternary because I hate "else" but it is kinda an else anyway.
However, no braces and then braces for this block pair was a bold move.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh yeah i might have had more than one line in there at one point
| // Perhaps this is a more generic 500 from the app, perhaps involving RERUM, and there is no good rerum_error_res | ||
| error.message = rerum_error_res.statusMessage ?? rerum_error_res.message ?? `A server error has occured` | ||
| } | ||
| error.status = rerum_error_res.statusCode ?? rerum_error_res.status ?? 500 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is correct and I hate it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a trip
| error.status = rerum_error_res.statusCode ?? rerum_error_res.status ?? 500 | ||
| console.error(error) | ||
| res.set("Content-Type", "text/plain; charset=utf-8") | ||
| res.status(error.status).send(error.message) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means messenger can never have a payload...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now. We didn't respond anywhere with a payload. If we end up wanting to do that we can upgrade the messenger.
| // Special handling. This does not go through to error-messenger.js | ||
| if (rerum_res.status === 409) { | ||
| const currentVersion = await rerum_res.json() | ||
| return res.status(409).json(currentVersion) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sends it, it doesn't keep going.
| if(res.headersSent) return | ||
| const result = await response.json() | ||
| // Send RERUM error responses to error-messenger.js | ||
| if (errored) return next(response) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The order of this makes me a little uneasy, but it works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes trying to keep separate what errors are here.
| throw new Error(`Error in overwrite request: ${err.status} ${err.statusText}`) | ||
| return rerum_res | ||
| }) | ||
| .catch(err => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why catch to only throw?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rest of them do it, so I thought maybe we did it for a reason. At least doing it to be consistent.

No description provided.