undici
undici copied to clipboard
Retrieve the URL when errored
This would solve...
When an error occured, it would be great to have requested URL which failed. It is just for logging and bugfixing purposes. Eg:
const pool = new Pool(domain);
try {
pool.request({
method: 'GET',
path: '/',
query: params,
throwOnError: true,
});
} catch (e) {
const failedUrl = magic_here;
throw new Error(`Request .... url: ${failedUrl}`);
}
Building this on my own would lead to different URL than actually was used. And it is very usefull for debbugging to know the actual URL from production environment.
The implementation should look like...
Ideally bind this property to UndiciError class.
I have also considered...
Also, export buildUrl from core/util.js. Only two properties from util.js are exported at this moment, but buildUrl is not one of them unfortunately.
Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.