Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ export default function devalue (value: any) {
Object.getOwnPropertyNames(proto).sort().join('\0') !== objectProtoOwnPropertyNames
) {
if (typeof thing.toJSON !== 'function') {
if (thing instanceof Error) {
const newMessage = `Cannot stringify error ${thing.constructor.name} since it is non-POJOs. Original error: ${thing.message}`
thing.message = newMessage
throw thing
}
log(`Cannot stringify arbitrary non-POJOs ${thing.constructor.name}`)
}
} else if (Object.getOwnPropertySymbols(thing).length > 0) {
Expand Down