Errors from switch expressions are a bit vague

Hello! I am writing to report an issue with the error messages coming from switch expressions. Specifically, the error message I received today was quite confusing and did not provide any useful information:

node:internal/process/promises:289
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "#<Object>".] {
  code: 'ERR_UNHANDLED_REJECTION'
}

I would greatly appreciate it if the error messages could be improved to provide more helpful information, just "#<Object>" was not very easy to understand.
Thank you.

I think it would help if you could share the code that triggered this error.

1 Like