When I throw a custom error in my server action, the client sees it as a normal Error:
export class MyCustomError extends Error {
constructor(message: string) {
super(message);
this.name = 'MyCustomError';
// Object.setPrototypeOf(this, MyCustomError.prototype);
}
}
'use server'
export async function someServerAction() {
throw new MyCustomError('blah blah blah')
}
try {
someServerAction()
} catch (err) {
console.log(err instance of MyCustomError) // false
console.log(err.name) // 'Error'
console.log(err instance of Error) // true
}