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

Include message type in TypedMessenger errors. #815

Open
jespertheend opened this issue Nov 14, 2023 · 1 comment
Open

Include message type in TypedMessenger errors. #815

jespertheend opened this issue Nov 14, 2023 · 1 comment
Labels
topic: TypedMessenger Related to the TypedMessenger class.
Milestone

Comments

@jespertheend
Copy link
Collaborator

jespertheend commented Nov 14, 2023

The stack trace from TypedMessenger errors can still be pretty unhelpful.
When using WebSockets for instance it will only list the WebSocket message event callback.

Extra information which could be included in the error message would be the name of the function that caused the error.

Also see #814

@jespertheend jespertheend added the topic: TypedMessenger Related to the TypedMessenger class. label Nov 14, 2023
@jespertheend jespertheend added this to the MVP milestone Nov 14, 2023
@jespertheend
Copy link
Collaborator Author

Actually it might be possible to 'fix' this stack trace. For instance, this doesn't print a useful stack trace:

async function foo() {
    await bar();
}

async function bar() {
    await new Promise((resolve, reject) => {
        setTimeout(() => {
            reject(new Error("oh no"))
        }, 1000);
    });
}

foo()

But this does:

async function foo() {
    await bar();
}

async function bar() {
    const p = new Promise((resolve, reject) => {
        setTimeout(() => {
            reject(new Error("oh no"))
        }, 1000);
    });

    try {
        await p;
    } catch (e) {
        e.stack = new Error().stack;
        throw e;
    }
}

foo()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: TypedMessenger Related to the TypedMessenger class.
Projects
None yet
Development

No branches or pull requests

1 participant