-
Notifications
You must be signed in to change notification settings - Fork 62
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
feat(connect): use extracted connection logic from mongosh MONGOSH-1080 #390
feat(connect): use extracted connection logic from mongosh MONGOSH-1080 #390
Conversation
src/utils/formatError.ts
Outdated
message: string; | ||
stack?: string; | ||
} => { | ||
if (err instanceof Error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to check whether something is a built-in Error
object, this is better:
if (err instanceof Error) { | |
if (Object.prototype.toString.call(err) === '[object Error]') { |
since instanceof
is not a reliable brand check in JS:
> vm.runInNewContext('new Error("banana")')
Error: banana
at evalmachine.<anonymous>:1:1
[… rest of stack …]
> vm.runInNewContext('new Error("banana")') instanceof Error
false
or alternatively I’d be more specific and just test whether the actual properties you’re looking for are present:
if (err instanceof Error) { | |
if (typeof err?.name === 'string' && typeof err?.message === 'string' && typeof err?.stack === 'string') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!! thank you for the suggestion! ❤️
Description
data-service
version to start using extracted connection logic from mongosh.connection-model
from dependencies.strictModuleExceptionHandling: true
because by default it false: https://webpack.js.org/configuration/output/#outputstrictmoduleerrorhandling. We needdevtools-connect
throw the error if can not resolveos-dns-native
: https://github.com/mongodb-js/devtools-connect/blob/main/src/connect.ts#L91.Checklist
Motivation and Context
Types of changes