forked from umijs/umi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.tsx
More file actions
40 lines (38 loc) · 973 Bytes
/
app.tsx
File metadata and controls
40 lines (38 loc) · 973 Bytes
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
import React from 'react';
import { Sentry, SentryRunTime } from 'umi';
import { ResponseError } from 'umi-request';
export const request = {
prefix: '',
method: 'post',
errorHandler: (error: ResponseError) => {
// 集中处理错误
console.log(error);
// throw error;
Sentry.captureException(error);
},
};
export const sentry = {
showDialog: true,
fallback: ({ error, componentStack, resetError }) =>
(
<React.Fragment>
<div>You have encountered an error</div>
{/* <div>{error.toString()}</div> */}
<div>{componentStack}</div>
<button
onClick={() => {
resetError();
}}
>
Click here to reset!
</button>
</React.Fragment>
) as React.ReactNode,
onError: (e) => {
console.error(e);
},
beforeCapture: (scope) => {
scope.setTag('location', 'first');
scope.setTag('anotherTag', 'anotherValue');
},
} as SentryRunTime;