-
Notifications
You must be signed in to change notification settings - Fork 70
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
fix(sdk-middleware-http): try json parse with catch block #1654
Conversation
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 👍
…s into try-catch-json-parse
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.
@daern91 any idea why it works with 11 ?
Codecov Report
@@ Coverage Diff @@
## master #1654 +/- ##
=======================================
Coverage 98.59% 98.59%
=======================================
Files 128 128
Lines 3347 3354 +7
Branches 774 775 +1
=======================================
+ Hits 3300 3307 +7
Misses 43 43
Partials 4 4
Continue to review full report at Codecov.
|
…s into try-catch-json-parse
@@ -63,7 +63,7 @@ export const customLineItem = [ | |||
slug: 'mySlug', | |||
taxCategory: { | |||
typeId: 'tax-category', | |||
id: 'fd890829-7554-4c22-a806-d6c6dcdbb0c5', | |||
id: 'd205cc42-e399-424a-b6fc-0ef44772d6bc', |
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.
changed it cause i accidentally deleted it
expect(data).toHaveLength(11) | ||
expect(data).toContainEqual(expect.objectContaining({type: 'CartCreated'})) | ||
expect(data).toContainEqual(expect.objectContaining({type: 'PaymentCreated'})) | ||
expect(data).toContainEqual(expect.objectContaining({type: 'CustomerCreated'})) | ||
expect(data).toContainEqual(expect.objectContaining({type: 'ReviewCreated'})) | ||
expect(data).toContainEqual(expect.objectContaining({type: 'OrderCreated'})) | ||
expect(data).toContainEqual(expect.objectContaining({type: 'CartCreated'})) | ||
expect(data).toContainEqual(expect.objectContaining({type: 'Order'})) | ||
expect(data).toContainEqual(expect.objectContaining({type: 'Cart'})) | ||
expect(data).toContainEqual(expect.objectContaining({email: 'foo@bar.de'})) | ||
expect(data).toContainEqual(expect.objectContaining({amountPlanned: { type: 'centPrecision', currencyCode: 'EUR', centAmount: 100, fractionDigits: 2}})) | ||
expect(data).toContainEqual(expect.objectContaining({name: {de: 'deutscherListenName', en: 'englishListName'}})) | ||
expect(data).toContainEqual(expect.objectContaining({text: 'Review text'})) |
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.
these checks to further be easy if new object were introduced
Summary
wrap json.parse with try and catch
Description
Wrapping it so in case we receive any invalid json, instead of directly parsing it which could lead to
Unexpected end of JSON input
, in this case, if there is any error then it get catch and then forwardbody
to consumer.