-
Notifications
You must be signed in to change notification settings - Fork 119
/
FatalErrorPage.jsx
160 lines (151 loc) · 5.7 KB
/
FatalErrorPage.jsx
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
import { FormattedMessage as T } from "react-intl";
import { KeyBlueButton, RemoveDaemonButton } from "buttons";
import { PageBody } from "layout";
import { ExternalLink } from "shared";
import { CopyToClipboardButton } from "buttons";
import { DIFF_CONNECTION_ERROR } from "constants";
import { wallet } from "wallet-preload-shim";
import { useFatalErrorPage } from "./hooks";
import styles from "./FatalErrorPage.module.css";
// right now we need to add logs by hand. It would be good having a better way
// of recognizing errors.
const resourcesUnavailableError = "resource temporarily unavailable";
const corruptedError = "corrupted";
const checkSumError = "checksum does not match";
function FatalErrorPage() {
const {
daemonError,
walletError,
isAdvancedDaemon,
shutdownApp,
backToCredentials,
deleteDaemonData
} = useFatalErrorPage();
const getErrorAction = () => {
let errorMessage;
switch (true) {
case daemonError.indexOf(resourcesUnavailableError) !== -1:
errorMessage = (
<T
id="fatal.suggestion.resources"
m="This error typically means you have another instance of daemon running. You should check your taskmanager or profiler to shutdown any still running daemon and then try again."
/>
);
break;
case daemonError.indexOf(DIFF_CONNECTION_ERROR) !== -1:
errorMessage = (
<>
<T
id="fatal.suggestion.diffConnection"
m="This error typically means you have the testnet flag in your dcrd.conf file. You should check your dcrd.conf file and remove the testnet=1."
/>
<div>config files path:{wallet.getAppDataDirectory()}</div>
</>
);
break;
case daemonError.indexOf(corruptedError) !== -1 ||
daemonError.indexOf(checkSumError) !== -1:
errorMessage = (
<>
<div className={styles.reset}>
<T
id="fatal.suggestion.corrupted"
m="This error means your blockchain data has somehow become corrupted. Typically, this is caused by a sector on the HDD/SDD that went bad and its built-in SMART didn't repair it, or the more likely case, there was a memory issue which corrupted the data. To resolve, you must delete your blockchain data and re-download. Press the button below to complete the process. When you restart Decrediton, it will automatically begin your blockchain download. Please come to our support channel on slack/matrix/discord to get advice about running disk utilities. "
/>
</div>
<RemoveDaemonButton
className={styles.removeButton}
modalTitle={
<T id="fatal.removeConfirmModal.title" m="Remove daemon data" />
}
modalContent={
<T
id="fatal.removeConfirmModal.content"
m="Warning this action is permanent! Please make sure you want to remove your blockchain data before proceeding. Decrediton will automatically shutdown after deleting the folder. Please manually restart it afterwards."
/>
}
onSubmit={deleteDaemonData}
buttonLabel={
<T id="fatal.button.delete" m="Delete and Shutdown" />
}
/>
</>
);
break;
default:
errorMessage = (
<T
id="fatal.suggestion.fallthrough"
m="Please note the error above and go to the support channel on matrix or some other preferred
chat channel for help resolving the issue. {link}"
values={{
link: (
<ExternalLink href="https://decred.org/community">
https://decred.org/community
</ExternalLink>
)
}}
/>
);
break;
}
return errorMessage;
};
return (
<PageBody>
<div className={styles.errorPage}>
<div className={styles.title}>
<T id="fatal.header.title" m="Fatal error" />:
</div>
<div>
<div>
{daemonError && (
<>
<div className={styles.error}>
<T id="fatal.daemon.title" m="Daemon Error" />
</div>
<textarea rows="10" value={daemonError} disabled />
<CopyToClipboardButton textToCopy={daemonError} />
</>
)}
{walletError && (
<>
<div className={styles.error}>
<T id="fatal.wallet.title" m="Wallet Error" />
</div>
<CopyToClipboardButton textToCopy={walletError} />
<textarea rows="10" value={walletError} disabled />
</>
)}
</div>
</div>
<div className={styles.title}>
<T
id="fatal.suggestion.title"
m="Suggested action to resolve the error"
/>
:
</div>
<div className={styles.suggestion}>
{daemonError && getErrorAction()}
</div>
<div className={styles.toolbar}>
{isAdvancedDaemon && (
<KeyBlueButton
className={styles.button}
onClick={backToCredentials}>
<T
id="fatal.retry.connection.button"
m="Return to Daemon Connection"
/>
</KeyBlueButton>
)}
<KeyBlueButton className={styles.button} onClick={shutdownApp}>
<T id="fatal.button" m="Close Decrediton" />
</KeyBlueButton>
</div>
</div>
</PageBody>
);
}
export default FatalErrorPage;