Skip to content

createPatch & createTwoFilesPatch throw meaningless exceptions if structuredPatch returns undefined #463

@ExplodingCabbage

Description

@ExplodingCabbage

Example:

> diff.createPatch("file1", "foo\nbar\n", "foodie\nbarbell", undefined, undefined, {maxEditLength: 1})
Uncaught TypeError: Cannot read properties of undefined (reading 'oldFileName')
    at formatPatch (/home/mark/jsdiff/lib/patch/create.js:241:12)
    at createTwoFilesPatch (/home/mark/jsdiff/lib/patch/create.js:270:10)
    at Object.createPatch (/home/mark/jsdiff/lib/patch/create.js:274:10)

We should propagate the failure that structuredPatch has signalled to us (by way of returning undefined) in a more useful way.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions