-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.js
More file actions
55 lines (50 loc) · 1.32 KB
/
errors.js
File metadata and controls
55 lines (50 loc) · 1.32 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
54
55
// Thrown when parameter(s) are missing/invalid
// See https://httpstatuses.com/422
class InvalidParameterError extends Error {
constructor (message) {
super()
this.name = 'InvalidParameterError'
this.message = message
}
}
// Thrown when request targets something permanently or temporarily missing
// See https://httpstatuses.com/404
class NotFoundError extends Error {
constructor (message) {
super()
this.name = 'NotFoundError'
this.message = message
}
}
/**
* Thrown when there's an error connecting to the ES index
*/
class IndexConnectionError extends Error {
constructor (message) {
super()
this.name = 'IndexConnectionError'
this.message = message
}
}
/**
* Thrown when there's an error parsing a query, typically due to user input.
* (Frequently due to bot traffic sending absolute nonsense.)
*/
class IndexSearchError extends Error {
constructor (message) {
super()
this.name = 'IndexSearchError'
this.message = message
}
}
/**
* Thrown when the user submits a query that cannot be parsed
*/
class InvalidQuerySyntaxError extends Error {
constructor (message) {
super()
this.name = 'InvalidQuerySyntaxError'
this.message = message
}
}
module.exports = { InvalidParameterError, NotFoundError, IndexConnectionError, IndexSearchError, InvalidQuerySyntaxError }