Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieve the URL when errored #3299

Open
mdorda opened this issue May 28, 2024 · 1 comment
Open

Retrieve the URL when errored #3299

mdorda opened this issue May 28, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@mdorda
Copy link

mdorda commented May 28, 2024

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.

@mdorda mdorda added the enhancement New feature or request label May 28, 2024
@mcollina
Copy link
Member

Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants