Uh oh!
There was an error while loading. Please reload this page.
This repository was archived by the owner on Dec 20, 2024. It is now read-only.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy patherrors.js
More file actions
Latest commit
49 lines (39 loc) · 1.77 KB
/
Copy patherrors.js
File metadata and controls
49 lines (39 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
'use strict'
functioncreateError(type,Proto){
constErr=function(message,cause){
if(typeofmessage==='object'&&message!==null){
// Can be passed just a cause
cause=cause||message
message=message.message||message.name
}
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(typeofcause==='object'&&cause.type===type&&cause.message===message){
returncause
}
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(typeofError.captureStackTrace==='function'){
Error.captureStackTrace(this,Err)
}
}
Err.prototype=newProto()
returnErr
}
constLevelUPError=createError('LevelUPError',Error)
module.exports={
LevelUPError: LevelUPError,
InitializationError: createError('InitializationError',LevelUPError),
OpenError: createError('OpenError',LevelUPError),
ReadError: createError('ReadError',LevelUPError),
WriteError: createError('WriteError',LevelUPError),
NotFoundError: createError('NotFoundError',LevelUPError),
EncodingError: createError('EncodingError',LevelUPError)
}
module.exports.NotFoundError.prototype.notFound=true
module.exports.NotFoundError.prototype.status=404