-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patherrors.js
More file actions
53 lines (41 loc) · 1.43 KB
/
Copy patherrors.js
File metadata and controls
53 lines (41 loc) · 1.43 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
50
51
52
53
function Failure(reason) {
this.book = {}
this.success = false
this.reason = reason
}
function thrower(methodName) {
throw Error('Cannot call ' + methodName + '() since the biblical reference is invalid - ' + this.reason)
}
Failure.prototype.toString = function() {
thrower.call(this, 'toString')
}
Failure.prototype.toShortString = function() {
thrower.call(this, 'toShortString')
}
Failure.prototype.getType = function() {
thrower.call(this, 'getType')
}
Failure.prototype.toSimpleObject = function() {
thrower.call(this, 'toSimpleObject')
}
Failure.prototype.next = function() {
thrower.call(this, 'next')
}
Failure.prototype.prev = function() {
thrower.call(this, 'prev')
}
const errors = {
book: new Failure('book does not exist'),
chapter: new Failure('chapter does not exist'),
verse: new Failure('verse does not exist'),
bookVersesFormat: new Failure('the "book verses" reference format only supports single chapter books'),
format: new Failure('the reference format is unrecognised'),
type: new Failure('the reference is not a string'),
nextBook: new Failure('next book does not exist'),
nextChapter: new Failure('next chapter does not exist'),
nextVerse: new Failure('next verse does not exist'),
prevBook: new Failure('previous book does not exist'),
prevChapter: new Failure('previous chapter does not exist'),
prevVerse: new Failure('previous verse does not exist')
}
module.exports = errors