-
Notifications
You must be signed in to change notification settings - Fork 169
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
Introduce a StatusCode
type to represent statuses
#474
Conversation
9760012
to
e67f2ca
Compare
|
||
impl fmt::Display for InvalidStatusCode { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
f.write_str("invalid status code") |
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.
without knowing the actuall invalid status code user (and so we are) helpless here.
Why to store error code?
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.
Clamping to http status code range (100..1000) for sanity and easier from str parsing (only 3 digits to parse).
NATS server doesn't use the entire range (need to double check but think we're using 400-600 currently) but leaving us some room for expansions.
Also heavily borrowing/yanking from the http crate here.
I think you're wanting to store the code that was deemed invalid in the error?
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.
yeah, that was my idea, to store that code here.
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.
Would require two errors at-least (because of the conversion its coming from is either str or u16), so punting for now if you don't mind 😁 (Really should not happen in normal flow from server).
b819d3c
to
fdaf332
Compare
This introduces a `StatusCode` type modeled after HTTP status codes but adapted to known NATS constants.
fdaf332
to
db948ea
Compare
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.
LGTM
No description provided.