Skip to content

Commit

Permalink
Better splitting of parse error message
Browse files Browse the repository at this point in the history
  • Loading branch information
Todor Petrov committed Apr 20, 2021
1 parent bcd2355 commit 418982a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/GotHttpAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class GotHttpAdapter implements HttpAdapter {

if (err instanceof GotParseError) {
throw new ParseError({
message: err.message.split(' in ')[0],
message: err.message.split(/\sin\s+"?https?:\/{2}/i, 1)[0],
responseBody: err.response.body,
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/tests/GotHttpAdapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ describe('GotHttpAdapter', () => {

it('should throw ParseError when got throws ParseError', async () => {
const parseError = produceFoolInstance(GotParseError, {
message: 'Unexpected token < at position 10 in http://example.com',
message: 'Unexpected token < at position 10 in "http://example.com"',
name: 'ParseError',
response: {
body: 'Invalid JSON',
Expand Down Expand Up @@ -380,7 +380,7 @@ describe('GotHttpAdapter', () => {

it('should throw ParseError when got throws ParseError', async () => {
const parseError = produceFoolInstance(GotParseError, {
message: 'Unexpected token < at position 10 in http://example.com',
message: 'Unexpected token < at position 10 in "http://example.com"',
name: 'ParseError',
response: {
body: 'Invalid JSON',
Expand Down

0 comments on commit 418982a

Please sign in to comment.