-
Notifications
You must be signed in to change notification settings - Fork 79
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
Error response wrapping #238
Conversation
Codecov Report
@@ Coverage Diff @@
## main #238 +/- ##
==========================================
+ Coverage 51.64% 51.65% +0.01%
==========================================
Files 37 37
Lines 8390 8392 +2
Branches 1789 1789
==========================================
+ Hits 4333 4335 +2
Misses 3743 3743
Partials 314 314
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
@@ -45,6 +45,13 @@ | |||
help=('Wraps the response in a response class') | |||
) | |||
|
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.
nit: Remove extra line
@@ -49,11 +49,11 @@ def fmt_obj(o): | |||
return json.dumps(o, indent=2) | |||
|
|||
|
|||
def fmt_error_type(data_type): | |||
def fmt_error_type(data_type, wrap_error_in=''): |
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.
nit: Can't we just default this to wrap_error_in='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.
We do need to default to '' becuase that is what comes in if the flag isn't set, so this would have to be checked when we call it and I think its better to abstract that here
stone/backends/js_helpers.py
Outdated
""" | ||
Converts the error type into a JSDoc type. | ||
""" | ||
return 'Error.<%s>' % fmt_type(data_type) | ||
return '%s.<%s>' % ((wrap_error_in if (wrap_error_in != '') else 'Error'), fmt_type(data_type)) |
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.
nit: And then update this to: return '%s.<%s>' % (wrap_error_in, fmt_type(data_type))
stone/backends/tsd_client.py
Outdated
@@ -67,6 +67,13 @@ | |||
help=('Wraps the response in a response class') | |||
) | |||
|
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.
nit: Remove extra line
@@ -41,13 +41,16 @@ | |||
} | |||
|
|||
|
|||
def fmt_error_type(data_type, inside_namespace=None): | |||
def fmt_error_type(data_type, inside_namespace=None, wrap_error_in=''): |
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.
nit: Same here - just default to wrap_error_in='Error'
""" | ||
Converts the error type into a TypeScript type. | ||
inside_namespace should be set to the namespace that the reference | ||
occurs in, or None if this parameter is not relevant. | ||
""" | ||
return 'Error<%s>' % fmt_type(data_type, inside_namespace) | ||
return '%s<%s>' % ( | ||
(wrap_error_in if (wrap_error_in != '') else '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.
nit: Same here - and then update to only wrap_error_in
Checklist
General Contributing
Is This a Code Change?
Validation
tox
?