以下のように記述することでErrorをJSON.stringify
できます。
const error = new Error('this is sample error')
console.log(JSON.stringify(error)) // このように記述すると{}となる
console.log(JSON.stringify(error, Object.getOwnPropertyNames(error)))
// {"stack":"Error: this is sample error\n at handleFetchError (/home/node/.next/server/chunks/745.js:227:23)\n at /home/node/.next/server/chunks/102.js:265:62\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async UserPage (/home/node/.next/server/chunks/102.js:287:20)","message":"this is sample error"}