-
Notifications
You must be signed in to change notification settings - Fork 2
/
ErrorHandler.js
76 lines (71 loc) · 2.11 KB
/
ErrorHandler.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import { setSystemError, setModalError } from "../../common/redux/core/actions";
import {
setSettingError,
showConfigScreen,
setStartupMode,
STARTUP_MODE,
} from "../../common/redux/config/actions";
export function handleError(store, error) {
let showBugModal = false;
let activeConfigTab = "";
let category = "generic";
let detail = "";
if (typeof error === "object" && "code" in error) {
switch (error.code) {
case "PROJECTERROR":
store.dispatch(setSettingError("workspace.project", error));
activeConfigTab = "workspace";
category = "project";
detail = error.code;
break;
case "EADDRINUSE":
case "EACESS":
case "EACCES":
store.dispatch(
setSettingError(
"workspace.server.port",
"The port is used by another application; please change it",
),
);
activeConfigTab = "server";
category = "network";
detail = error.code;
break;
case "EADDRNOTAVAIL":
store.dispatch(
setSettingError(
"workspace.server.hostname",
"The hostname is not local address; only use hostnames/IPs associated with this machine",
),
);
activeConfigTab = "server";
category = "network";
detail = error.code;
break;
case "CUSTOMERROR":
store.dispatch(setSettingError(error.key, error.value));
store.dispatch(setStartupMode(STARTUP_MODE.NEW_WORKSPACE));
activeConfigTab = error.tab;
category = "custom";
detail = error.key + " - " + error.value;
break;
case "MODALERROR":
store.dispatch(setModalError(error));
return;
default:
showBugModal = true;
category = "generic";
detail = error.code;
break;
}
} else {
showBugModal = true;
category = "generic";
detail = JSON.stringify(error);
}
store.dispatch(setSystemError(error, showBugModal, category, detail));
if (!showBugModal) {
// show the config screen
store.dispatch(showConfigScreen(activeConfigTab));
}
}