(err: Error | string)
| 45 | * @param err 错误 |
| 46 | */ |
| 47 | export async function error(err: Error | string) { |
| 48 | initSentry(); // 确保Sentry被初始化 |
| 49 | |
| 50 | let fn; |
| 51 | if (typeof err === 'string') { |
| 52 | fn = Sentry.captureMessage.bind(Sentry); |
| 53 | } else { |
| 54 | fn = Sentry.captureException.bind(Sentry); |
| 55 | } |
| 56 | const context: CaptureContext = { |
| 57 | contexts: { |
| 58 | token: { |
| 59 | ...(await getJWTUserInfo()), |
| 60 | }, |
| 61 | }, |
| 62 | }; |
| 63 | const sentryId = fn(err, context); |
| 64 | console.warn('error: sentryId', sentryId); |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * 设置用户信息操作 |
nothing calls this directly
no test coverage detected