I have a situation with a derived class on Error that has some extra properties on it. I'd like to be able to create that child class using the parent Error class, but can't figure it out for the life of me.
For example something like:
class FooError extends Error {
constructor(er: Error, public extra?: string) {
super(er.message)
Object.assign(this, er)
}
}
function handleError(e: Error) {
throw new FooError(e, "abc") // rethrow
}
That can't possibly be right though, thanks for your help!