@friggframework/errors
Advanced tools
Comparing version 1.1.6-canary.103.e147906.0 to 1.1.6-canary.124.e030db1.0
@@ -13,3 +13,10 @@ const { BaseError } = require('./base-error'); | ||
const method = init?.method ?? 'GET'; | ||
const initText = init ? JSON.stringify({ init }, null, 2) : ''; | ||
const initText = init | ||
? init.body instanceof URLSearchParams | ||
? (() => { | ||
init.body = init.body.toString(); | ||
return JSON.stringify({ init }, null, 2); | ||
})() | ||
: JSON.stringify({ init }, null, 2) | ||
: ''; | ||
@@ -16,0 +23,0 @@ let responseBodyText = '<response body is unavailable>'; |
const fetch = require('node-fetch'); | ||
const { stripIndent } = require('common-tags'); | ||
const { FetchError } = require('./fetch-error'); | ||
const FormData = require('form-data'); | ||
@@ -54,2 +55,26 @@ describe('FetchError', () => { | ||
}); | ||
it.only('prints a formData body legibly', async () => { | ||
const response = { | ||
status: 500, | ||
statusText: 'Space aliens!', | ||
headers: Object.entries({ 'cache-control': '123' }), // needs to be an Iterable | ||
text: async () => '<!doctype html>', | ||
}; | ||
const params = new URLSearchParams(); | ||
params.append('test', 'test'); | ||
const init = { | ||
method: 'POST', | ||
credentials: 'include', | ||
headers: {}, | ||
query: {}, | ||
body: params, | ||
returnFullRes: false, | ||
}; | ||
const error = await FetchError.create({ response, init }); | ||
expect(error).toHaveProperty('message'); | ||
expect(error.message).toContain('test=test'); | ||
}); | ||
}); |
{ | ||
"name": "@friggframework/errors", | ||
"version": "1.1.6-canary.103.e147906.0", | ||
"version": "1.1.6-canary.124.e030db1.0", | ||
"prettier": "@friggframework/prettier-config", | ||
@@ -8,3 +8,3 @@ "description": "", | ||
"devDependencies": { | ||
"@friggframework/eslint-config": "1.0.9-canary.103.e147906.0", | ||
"@friggframework/eslint-config": "^1.0.8", | ||
"eslint": "^8.22.0", | ||
@@ -23,3 +23,3 @@ "jest": "^28.1.3", | ||
}, | ||
"gitHead": "e14790648eccf3699d4b163f21a56d00d00ecc57" | ||
"gitHead": "e030db1c862f6c0d01f8ab7517804af02df46ac0" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16906
346