Description
if one of the screenshots submitted for comparison is empty, an error is thrown:
RangeError [ERR_BUFFER_OUT_OF_BOUNDS]: Attempt to access memory outside buffer bounds
According to this error, the user does not understand what the problem is. So before reading the buffer, we need to check if it is empty. If it is empty, then we throw an understandable error. It would be even better to validate that the buffer is a png image.
Verify latest release
Reproduction steps
- Create empty file -
empty.png
- Run script:
const looksSame = require('looks-same');
(async () => {
await looksSame('./empty.png', './empty.png');
})();
Actual Behavior
Get an incomprehensible error when starting the comparison of an empty image:
RangeError [ERR_BUFFER_OUT_OF_BOUNDS]: Attempt to access memory outside buffer bounds
Expected Behavior
Get an understandable error when starting the comparison of an empty image, for example:
File "empty.png" is not a valid png image
Which Node.js version are you using?
20.18.1
Description
if one of the screenshots submitted for comparison is empty, an error is thrown:
According to this error, the user does not understand what the problem is. So before reading the buffer, we need to check if it is empty. If it is empty, then we throw an understandable error. It would be even better to validate that the buffer is a png image.
Verify latest release
Reproduction steps
empty.pngActual Behavior
Get an incomprehensible error when starting the comparison of an empty image:
Expected Behavior
Get an understandable error when starting the comparison of an empty image, for example:
Which Node.js version are you using?
20.18.1