Link to the code that reproduces this issue
https://github.com/carlos-dubon/nextjs-error-bug
To Reproduce
// app/page.tsx
async function getData(): Promise<number> {
throw {
message: 'MY CUSTOM ERROR',
name: 'My new error',
cause: 'custom error',
};
return 3;
}
export default async function Home() {
const pageData = await getData();
return (
<div>{pageData}</div>
);
}
Current vs. Expected behavior
Throwing a custom error object appears as [Object object]
in my app/error.ts
file. I get a digest but the error is still [Object object] so it isn’t helpful at all. I need this because our apps use a common package for calling our apis, and i can’t simply modify it to suit only our web app.
Provide environment information
Operating System:
Platform: win32
Arch: x64
Version: Windows 11 Pro
Binaries:
Node: 20.10.0
npm: N/A
Yarn: N/A
pnpm: N/A
Relevant Packages:
next: 14.1.0
eslint-config-next: 14.1.0
react: 18.2.0
react-dom: 18.2.0
typescript: 5.3.3
Next.js Config:
output: N/A