Files
puter/tests/api-tester/lib/log_error.js
Xiaochen Cui c93a53ead2 ci: init e2e test for browser env, tidy other tests (#1796)
* ci: init e2e test for browser env

stash changes

* test: update fsentry definition, add tests

stash changes

* test: pass puter-js mkdir test

* test: add test for puter-js move

* tidy code

* tidy code

* doc: add docs for playwright test

* recover memoryfs

* test: puter-js readdir/stat

* test: puter-js write

* test: puter-js read

* test: puter-js move_cart

* test: fix failed tests on move

* tests: rename files

* test: puter-js copy_cart

* tests: puter-js batch/delete, read config from file

* ci: add vitest

* ci: update names and timeout

* ci: simplify playwright-test

* ci: simplify api-test

* move "api-tester" from tools to tests

* test: update example config

* test: remove folder tests/api-tester/ci

* test: unify config location

* test: remove unused files

* ci: fix wrong config

* ci: fix wrong path

* test: add docs

* ci: update timeout, print artifact url
2025-10-28 16:35:37 -07:00

35 lines
938 B
JavaScript

const log_http_error = e => {
console.log('\x1B[31;1m' + e.message + '\x1B[0m');
console.log('HTTP Method: ', e.config.method.toUpperCase());
console.log('URL: ', e.config.url);
if (e.config.params) {
console.log('URL Parameters: ', e.config.params);
}
if (e.config.method.toLowerCase() === 'post' && e.config.data) {
console.log('Post body: ', e.config.data);
}
console.log('Request Headers: ', JSON.stringify(e.config.headers, null, 2));
if (e.response) {
console.log('Response Status: ', e.response.status);
console.log('Response Headers: ', JSON.stringify(e.response.headers, null, 2));
console.log('Response body: ', e.response.data);
}
console.log('\x1B[31;1m' + e.message + '\x1B[0m');
};
const log_error = e => {
if ( e.request ) {
log_http_error(e);
return;
}
console.error(e);
};
module.exports = log_error;