Intercepting and affecting a custom Error object in Javascript

I use a custom javascript module that has its own error Objects. I want to catch these custom error objects and use the appropriate path in my folder try {} catch {} block them from the built in javascript error objects like ReferenceError, TypeError etc.

A little bit like that.

To attempt {
// A code that can cause a traditional javascript error
// or one of the bugs of the module I am using.
} catch {error} {
if (error instance of ExchangeError) {
// Treat it that way.
}otherwise{
// Probably one of the built-in Javascript errors,
// So do the other one.
}
}

So in the example above Exchange Error is a custom error associated with this particular module, but I can not do this Beispielvon on my mistake, although I do that error.constructor.name I get Exchange Error,

My javascript area just does not know that Exchange Error, The question is, how can I intercept such error objects? I'm sure I can do it with string matching, but I just wanted to check if there is a more elegant way.

I tried one thing, I have my own error Module that contains some custom errors, I've tried to mimic the module's error object:

                Class ExchangeError extends error {
Constructor (message) {
great (message);
this.constructor = ExchangeError;
this .__ proto__ = ExchangeError.prototype;
this.message = message;
}
}

and import that through mine error Module, but that obviously did not work.