Repository navigation
Expand file tree
/
Copy patherrors.js
More file actions
55 lines (47 loc) · 1.65 KB
/
Copy patherrors.js
File metadata and controls
55 lines (47 loc) · 1.65 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
"use strict";
var Errors = function(){
var _errors = [];
var errorCode = function (name) {
for (var i = 0; i < _errors.length; i++) {
if (_errors[i]["name"] === name) {
return i;
}
}
// Don't have 42 error messages
return 42;
};
var errorMessage = function (code) {
return _errors[code]["message"];
};
var error = {
"code": errorCode,
"message": errorMessage
};
var addError = function (name, message) {
if (name == "code" || name == "message") {
return;
}
if (_errors.length == 42) {
_errors.push({
"name": "answer_to_the_ultimate_question_of_life_the_universe_and_everything",
"message": "You just found the Answer to the Ultimate Question of Life, The Universe, and Everything!"
});
}
_errors.push({
"name": name,
"message": message
});
error[name] = _errors.length - 1;
};
addError("no_error", "There were no errors.");
addError("unknown_error", "I don't know why it didn't work. :(");
addError("connection_error", "The bot couldn't connect to the API server");
addError("no_keys_usable", "Apparently you have keys with quota left.");
addError("invalid_key", "The key is invalid.");
addError("infinite_loop_detected", "Loop-Loop-Loop");
addError("malformed_response", "The bot couldn't parse the API servers response.");
addError("no_results", "I couldn't find any images for you :(");
addError("empty_response", "The search API acted strange...");
return error;
};
var exports = module.exports = Errors();