level-errors
Advanced tools
Comparing version
# Changelog | ||
_**If you are upgrading:** please see [`UPGRADING.md`](UPGRADING.md)._ | ||
## [3.0.1] - 2021-09-24 | ||
### Fixed | ||
- Don't wrap existing errors ([#37](https://github.com/Level/errors/issues/37)) ([`189f2b1`](https://github.com/Level/errors/commit/189f2b1)) (Vincent Weevers) | ||
## [3.0.0] - 2021-04-09 | ||
_If you are upgrading: please see [`UPGRADING.md`](UPGRADING.md)._ | ||
### Changed | ||
@@ -36,2 +42,4 @@ | ||
_If you are upgrading: please see [`UPGRADING.md`](UPGRADING.md)._ | ||
### Changed | ||
@@ -113,6 +121,8 @@ | ||
## 1.0.1 - 2015-03-20 | ||
## [1.0.1] - 2015-03-20 | ||
:seedling: Initial release. | ||
[3.0.1]: https://github.com/Level/errors/compare/v3.0.0...v3.0.1 | ||
[3.0.0]: https://github.com/Level/errors/compare/v2.0.1...v3.0.0 | ||
@@ -137,1 +147,3 @@ | ||
[1.0.2]: https://github.com/Level/errors/compare/v1.0.1...v1.0.2 | ||
[1.0.1]: https://github.com/Level/errors/releases/tag/v1.0.1 |
'use strict' | ||
const createError = require('errno').create | ||
const LevelUPError = createError('LevelUPError') | ||
const NotFoundError = createError('NotFoundError', LevelUPError) | ||
function createError (type, Proto) { | ||
const Err = function (message, cause) { | ||
if (typeof message === 'object' && message !== null) { | ||
// Can be passed just a cause | ||
cause = cause || message | ||
message = message.message || message.name | ||
} | ||
NotFoundError.prototype.notFound = true | ||
NotFoundError.prototype.status = 404 | ||
message = message || '' | ||
cause = cause || undefined | ||
// If input is already of type, return as-is to keep its stack trace. | ||
// Avoid instanceof, for when node_modules has multiple copies of level-errors. | ||
if (typeof cause === 'object' && cause.type === type && cause.message === message) { | ||
return cause | ||
} | ||
Object.defineProperty(this, 'type', { value: type, enumerable: false, writable: true, configurable: true }) | ||
Object.defineProperty(this, 'name', { value: type, enumerable: false, writable: true, configurable: true }) | ||
Object.defineProperty(this, 'cause', { value: cause, enumerable: false, writable: true, configurable: true }) | ||
Object.defineProperty(this, 'message', { value: message, enumerable: false, writable: true, configurable: true }) | ||
Error.call(this) | ||
if (typeof Error.captureStackTrace === 'function') { | ||
Error.captureStackTrace(this, Err) | ||
} | ||
} | ||
Err.prototype = new Proto() | ||
return Err | ||
} | ||
const LevelUPError = createError('LevelUPError', Error) | ||
module.exports = { | ||
@@ -16,4 +44,7 @@ LevelUPError: LevelUPError, | ||
WriteError: createError('WriteError', LevelUPError), | ||
NotFoundError: NotFoundError, | ||
NotFoundError: createError('NotFoundError', LevelUPError), | ||
EncodingError: createError('EncodingError', LevelUPError) | ||
} | ||
module.exports.NotFoundError.prototype.notFound = true | ||
module.exports.NotFoundError.prototype.status = 404 |
{ | ||
"name": "level-errors", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "Error types for levelup", | ||
@@ -10,3 +10,3 @@ "license": "MIT", | ||
"test-browsers-local": "airtap --coverage test.js", | ||
"coverage": "nyc report --reporter=text-lcov | coveralls", | ||
"coverage": "nyc report -r lcovonly", | ||
"hallmark": "hallmark --fix", | ||
@@ -19,16 +19,9 @@ "dependency-check": "dependency-check . test.js", | ||
"CHANGELOG.md", | ||
"CONTRIBUTORS.md", | ||
"LICENSE.md", | ||
"UPGRADING.md" | ||
], | ||
"dependencies": { | ||
"errno": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"airtap": "^4.0.3", | ||
"airtap-playwright": "^1.0.1", | ||
"coveralls": "^3.0.2", | ||
"dependency-check": "^3.3.0", | ||
"hallmark": "^3.1.0", | ||
"level-community": "^3.0.0", | ||
"nyc": "^15.1.0", | ||
@@ -38,5 +31,2 @@ "standard": "^16.0.3", | ||
}, | ||
"hallmark": { | ||
"community": "level-community" | ||
}, | ||
"repository": { | ||
@@ -43,0 +33,0 @@ "type": "git", |
@@ -6,10 +6,9 @@ # level-errors | ||
[![level badge][level-badge]](https://github.com/Level/awesome) | ||
[](https://www.npmjs.com/package/level-errors) | ||
[](https://www.npmjs.com/package/level-errors) | ||
[](https://www.npmjs.com/package/level-errors) | ||
[](https://travis-ci.com/Level/errors) | ||
[](https://coveralls.io/github/Level/errors) | ||
[](https://standardjs.com) | ||
[](https://www.npmjs.com/package/level-errors) | ||
[](#backers) | ||
[](#sponsors) | ||
[](https://github.com/Level/errors/actions/workflows/test.yml) | ||
[](https://codecov.io/gh/Level/errors) | ||
[](https://standardjs.com) | ||
[](https://common-changelog.org) | ||
[](https://opencollective.com/level) | ||
@@ -63,15 +62,7 @@ ## API | ||
To sustain [`Level`](https://github.com/Level) and its activities, become a backer or sponsor on [Open Collective](https://opencollective.com/level). Your logo or avatar will be displayed on our 28+ [GitHub repositories](https://github.com/Level) and [npm](https://www.npmjs.com/) packages. 💖 | ||
Support us with a monthly donation on [Open Collective](https://opencollective.com/level) and help us continue our work. | ||
### Backers | ||
[](https://opencollective.com/level) | ||
### Sponsors | ||
[](https://opencollective.com/level) | ||
## License | ||
[MIT](LICENSE.md) © 2012-present [Contributors](CONTRIBUTORS.md). | ||
[MIT](LICENSE) | ||
@@ -78,0 +69,0 @@ [level-badge]: https://leveljs.org/img/badge.svg |
0
-100%7
-22.22%39
160%13123
-1.25%6
-14.29%70
-11.39%- Removed
- Removed
- Removed