jimp icon indicating copy to clipboard operation
jimp copied to clipboard

`getBufferAsync()` throws a string instead of an Error

Open nopeless opened this issue 2 years ago • 3 comments

Expected Behavior

    Jimp.read(v)
      .then(lenna => lenna.resize(2000, Jimp.AUTO).getBufferAsync(`png`))
      .catch(e => {
        console.log(`type of e`, typeof e);
        throw e;
      })

Should log object

Current Behavior

logs string

Failure Information (for bugs)

Steps to Reproduce

Here is a minimal reproducible example

import Jimp from "jimp";

Jimp.read(`response.png`)
  .then(lenna => lenna.resize(2000, Jimp.AUTO).getBufferAsync(`png`))
  .catch(e => {
    console.log(`type of e should be object`, typeof e);
    console.log(`e should be an instance of Error`, e instanceof Error);
  });

Context

  • Jimp Version: 0.16.1
  • Operating System: windows 10
  • Node version: 16.13.1

I am reporting this error because this broke my error catching express middleware.

image

Before the fix

Fixing by doing

      .catch(e => {
        console.log(`type of e`, typeof e);
        throw new Error(e);
      })

After the fix

image

Hope to see this fixed soon 👍

nopeless avatar Jan 04 '22 18:01 nopeless

bump

nopeless avatar Apr 17 '22 06:04 nopeless

'png' written like this isn't a MIME type ! Replace .getBufferAsync(`png`) with .getBufferAsync(Jimp.MIME_PNG) instead

intradeus avatar Jul 26 '22 19:07 intradeus

@intradeus @noahdeering can you please read. the issue states that the function is throwing a string not an error

nopeless avatar Jul 30 '22 05:07 nopeless