nodeca / probe-image-size

Get image size without full download. Supported image types: JPG, GIF, PNG, WebP, BMP, TIFF, SVG, PSD, ICO.
MIT License
978 stars 77 forks source link

Probe Error Fix #71

Closed ScotteRoberts-wm closed 2 years ago

ScotteRoberts-wm commented 2 years ago

There is an issue when running this code in Firefox. I have added an if statement to guard against Error.captureStackTrace being undefined.

Code Fix:

function ProbeError(message, code, statusCode) {
  Error.call(this);
  if (Error.captureStackTrace) Error.captureStackTrace(this, this.constructor);

  this.name = this.constructor.name;

  this.message = message;
  if (code) this.code = code;
  if (statusCode) this.statusCode = statusCode;
}

Resource: https://developer.mozilla.org/en-US/docs/web/javascript/reference/global_objects/error#custom_error_types

ScotteRoberts-wm commented 2 years ago

@puzrin I was wondering if a code change would be made for the bug? 😄