-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsheetError.js
55 lines (45 loc) · 1.43 KB
/
sheetError.js
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
/**
* Error logging functions. See file for exported functions (Didn't bother with documentation)
* @module sheetError
*/
module.exports = {
sheetIdErr: sheetIdError,
worksheetErr: worksheetError,
genericErr: genericError,
specificErr: specificError,
unexpectedErr: unexpectedError,
handledErr: handledError,
nonErr: nonErrorError,
throwErr: throwError
}
function sheetIdError(err, optionalText) {
errorLog(`Invalid Sheet ID${optionalErrDetail(optionalText)}:`, err);
}
function worksheetError(err, optionalText) {
errorLog(`Invalid Worksheet${optionalErrDetail(optionalText)}`, err);
}
function genericError(err, optionalText) {
errorLog(`Generic Error${optionalErrDetail(optionalText)}`, err, "\nGet more specific with error handling to debug.");
}
function specificError(err, errorMessage) {
errorLog(`Definite <${optionalErrDetail(errorMessage)}>`, err);
}
function unexpectedError(err, optionalText) {
errorLog(`Unexpected Error in Bagging Area${optionalErrDetail(optionalText)}`, err);
}
function optionalErrDetail(detail) {
return (detail ? detail : "");
}
function handledError(handledText) {
console.log(handledText);
}
function nonErrorError(errText) {
console.log(errText);
}
function throwError(errText, optionalText) {
if(optionalText) console.log(optionalText);
throw errText;
}
function errorLog(name, text, detail) {
console.log("\x1b[31m%s:\x1b[0m %s \x1b[32m%s\x1b[0m", name, text, optionalErrDetail(detail))
}