Create a JSON replacer function that converts Error objects into plain objects
containing their non-enumerable properties (name, message, stack, cause, etc.)
along with any enumerable properties.
This function can be used as a base replacer to ensure that Error objects are
properly serialized during JSON serialization, and can be combined with a user-defined
replacer for additional customization.
Parameters
Optionalreplacer: JsonReplacer
An optional user-defined replacer (function or property list) to apply after the Error replacer.
Returns JsonReplacerFunction
A JSON replacer function that handles Error objects and applies the user-defined replacer if provided.
Create a JSON replacer function that converts Error objects into plain objects containing their non-enumerable properties (name, message, stack, cause, etc.) along with any enumerable properties.
This function can be used as a base replacer to ensure that Error objects are properly serialized during JSON serialization, and can be combined with a user-defined replacer for additional customization.