MCPcopy Create free account
hub / github.com/linuxfoundation/crowd.dev / handle

Method handle

frontend/src/shared/error/errors.js:45–94  ·  view source on GitHub ↗
(error)

Source from the content-addressed store, hash-verified

43
44export default class Errors {
45 static handle(error) {
46 const { captureException } = useLogRocket();
47
48 captureException(error);
49
50 if (import.meta.env.NODE_ENV !== 'test') {
51 console.error(selectErrorMessage(error));
52 console.error(error);
53 }
54
55 if (selectErrorCode(error) === 401) {
56 AuthService.signout();
57 window.location.reload();
58 return;
59 }
60
61 if (selectErrorCode(error) === 403) {
62 if (error.config.url.includes('member/export')) {
63 // we'll be handling these differently
64 return;
65 }
66
67 if (
68 error.response.data.includes('Missing scopes in ')
69 ) {
70 Message.error(error.response.data, { duration: 0 });
71 return;
72 }
73 router.push('/403');
74 return;
75 }
76
77 if ([400, 409, 429].includes(selectErrorCode(error))) {
78 Message.error(selectErrorMessage(error));
79 return;
80 }
81
82 if (selectErrorCode(error) === 542) {
83 Message.error(
84 'An error has occurred setting up the integration, please reach out to us via chat, or via email (help@crowd.dev)',
85 { duration: 0 },
86 );
87 return;
88 }
89
90 Message.error(
91 'Please try again. If the problem remains, reach out to us.',
92 { title: 'Oops, something went wrong' },
93 );
94 }
95
96 static errorCode(error) {
97 return selectErrorCode(error);

Callers 15

doFetchFunction · 0.80
doDestroyFunction · 0.80
doDestroyAllFunction · 0.80
doFindFunction · 0.80
doGithubConnectFunction · 0.80
doRedditOnboardFunction · 0.80
doLinkedinConnectFunction · 0.80
doLinkedinOnboardFunction · 0.80
doDiscordConnectFunction · 0.80
doDevtoConnectFunction · 0.80
doHackerNewsConnectFunction · 0.80
doStackOverflowOnboardFunction · 0.80

Calls 6

useLogRocketFunction · 0.90
captureExceptionFunction · 0.85
selectErrorMessageFunction · 0.85
selectErrorCodeFunction · 0.85
signoutMethod · 0.80
errorMethod · 0.45

Tested by

no test coverage detected