Skip to content

Commit

Permalink
Fix custom error in FF
Browse files Browse the repository at this point in the history
close #71
  • Loading branch information
Vitaly Puzrin committed Jan 27, 2022
1 parent bd207a5 commit 1872124
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [7.2.3] - 2022-01-27
### Fixed
- Fix `Error` extend in FF, #71.


## [7.2.2] - 2021-10-12
### Fixed
- Skip invalid chunks in JPEG parser instead of stopping, so some broken images can still be parsed, #68.
Expand Down Expand Up @@ -215,6 +220,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- First release.


[7.2.3]: https://github.com/nodeca/probe-image-size/compare/7.2.2...7.2.3
[7.2.2]: https://github.com/nodeca/probe-image-size/compare/7.2.1...7.2.2
[7.2.1]: https://github.com/nodeca/probe-image-size/compare/7.2.0...7.2.1
[7.2.0]: https://github.com/nodeca/probe-image-size/compare/7.1.1...7.2.0
Expand Down
10 changes: 9 additions & 1 deletion lib/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,15 @@ exports.readUInt32BE = function (data, offset) {

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

// Include stack trace in error object
if (Error.captureStackTrace) {
// Chrome and NodeJS
Error.captureStackTrace(this, this.constructor);
} else {
// FF, IE 10+ and Safari 6+. Fallback for others
this.stack = (new Error()).stack || '';
}

this.name = this.constructor.name;

Expand Down

0 comments on commit 1872124

Please sign in to comment.