Skip to content

Better error for writeFile where obj is undefined #167

Description

@RyanZim

const str = JSON.stringify(obj, replacer, spaces)
return str.replace(/\n/g, EOL) + EOF

JSON.stringify() can return undefined when obj is undefined (or a bare function, or a Symbol), which would cause str.replace(...) to throw TypeError: Cannot read properties of undefined. We should add some basic type-checking here, and throw with a more intelligent error message for these cases.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions