sync-request-curl
Advanced tools
Comparing version 1.0.4 to 1.1.0
@@ -58,3 +58,13 @@ "use strict"; | ||
if (code !== node_libcurl_1.CurlCode.CURLE_OK) { | ||
throw new Error(`This shouldn't happen :(. Curl request failed with code: ${code}`); | ||
throw new Error(` | ||
Curl request failed with code ${code} | ||
Please look up libcurl error code! | ||
- https://curl.se/libcurl/c/libcurl-errors.html | ||
DEBUG: { | ||
method: "${method}", | ||
url: "${url}", | ||
options: ${JSON.stringify(options)} | ||
} | ||
`); | ||
} | ||
@@ -71,3 +81,10 @@ const statusCode = curl.getInfo('RESPONSE_CODE').data; | ||
if (statusCode >= 300) { | ||
throw new Error(`Server responded with status code ${statusCode}\n${body.toString()}\nUse 'res.body' instead of 'res.getBody()' to not have any errors thrown.`); | ||
throw new Error(` | ||
Server responded with status code ${statusCode} | ||
Body: ${body.toString()} | ||
Use 'res.body' instead of 'res.getBody()' to not have any errors thrown. | ||
The status code (in this case, ${statusCode}) can be checked manually with res.statusCode. | ||
`); | ||
} | ||
@@ -74,0 +91,0 @@ return encoding ? body.toString(encoding) : body; |
@@ -55,3 +55,13 @@ // const request = require('sync-curl'); | ||
if (code !== CurlCode.CURLE_OK) { | ||
throw new Error(`This shouldn't happen :(. Curl request failed with code: ${code}`); | ||
throw new Error(` | ||
Curl request failed with code ${code} | ||
Please look up libcurl error code! | ||
- https://curl.se/libcurl/c/libcurl-errors.html | ||
DEBUG: { | ||
method: "${method}", | ||
url: "${url}", | ||
options: ${JSON.stringify(options)} | ||
} | ||
`); | ||
} | ||
@@ -68,3 +78,10 @@ const statusCode = curl.getInfo('RESPONSE_CODE').data; | ||
if (statusCode >= 300) { | ||
throw new Error(`Server responded with status code ${statusCode}\n${body.toString()}\nUse 'res.body' instead of 'res.getBody()' to not have any errors thrown.`); | ||
throw new Error(` | ||
Server responded with status code ${statusCode} | ||
Body: ${body.toString()} | ||
Use 'res.body' instead of 'res.getBody()' to not have any errors thrown. | ||
The status code (in this case, ${statusCode}) can be checked manually with res.statusCode. | ||
`); | ||
} | ||
@@ -71,0 +88,0 @@ return encoding ? body.toString(encoding) : body; |
@@ -7,3 +7,3 @@ { | ||
}, | ||
"version": "1.0.4", | ||
"version": "1.1.0", | ||
"files": [ | ||
@@ -17,3 +17,4 @@ "dist" | ||
"build:esm": "tsc", | ||
"build:cjs": "tsc --module CommonJS --outDir dist/cjs" | ||
"build:cjs": "tsc --module CommonJS --outDir dist/cjs", | ||
"prepublishOnly": "npm run build" | ||
}, | ||
@@ -20,0 +21,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
24434
284