Skip to content
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

Merged
merged 8 commits into from Jun 24, 2021
Merged

Error response wrapping #238

merged 8 commits into from Jun 24, 2021

Conversation

rogebrd
Copy link
Contributor

@rogebrd rogebrd commented Jun 23, 2021

Checklist

General Contributing

  • Have you read the Code of Conduct and signed the CLA?

Is This a Code Change?

  • Non-code related change (markdown/git settings etc)
  • Code Change
  • Example/Test Code Change

Validation

  • Have you ran tox?
  • Do the tests pass?

@codecov
Copy link

codecov bot commented Jun 23, 2021

Codecov Report

Merging #238 (f61f704) into main (35121e8) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            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              
Flag Coverage Δ
unit 51.65% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
stone/backends/js_client.py 78.08% <100.00%> (+0.30%) ⬆️
stone/backends/js_helpers.py 65.30% <100.00%> (ø)
stone/backends/tsd_client.py 55.91% <100.00%> (+0.47%) ⬆️
stone/backends/tsd_helpers.py 48.68% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 35121e8...f61f704. Read the comment docs.

@@ -45,6 +45,13 @@
help=('Wraps the response in a response class')
)

Copy link
Contributor

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=''):
Copy link
Contributor

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'

Copy link
Contributor Author

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

"""
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))
Copy link
Contributor

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))

@@ -67,6 +67,13 @@
help=('Wraps the response in a response class')
)

Copy link
Contributor

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=''):
Copy link
Contributor

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'),
Copy link
Contributor

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

@rogebrd rogebrd merged commit c1d8f0d into main Jun 24, 2021
@rogebrd rogebrd deleted the error_response_wrapping branch June 24, 2021 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants