File tree Expand file tree Collapse file tree 4 files changed +24
-8
lines changed
Expand file tree Collapse file tree 4 files changed +24
-8
lines changed Original file line number Diff line number Diff line change 77
88import { getUserToken } from '../redux/commonStore' ;
99import { CustomError } from '../utils/types/CustomError' ;
10+ import { NetworkTimeoutError } from '../utils/types/NetworkTimeoutError' ;
1011
1112const DEFAULT_TIMEOUT_MS = 50_000 ;
1213
@@ -16,14 +17,6 @@ type FetchInitWithTimeout = RequestInit & {
1617 timeoutMs ?: number ;
1718} ;
1819
19- /** Custom error type thrown when AbortSignal.timeout triggers. */
20- export class NetworkTimeoutError extends Error {
21- constructor ( messageKey : string = 'errors.network.timeout' ) {
22- super ( messageKey ) ;
23- this . name = 'NetworkTimeoutError' ;
24- }
25- }
26-
2720const parseError = ( text : string ) => {
2821 try {
2922 return JSON . parse ( text ) ;
Original file line number Diff line number Diff line change 66 */
77import { SnackInputs , UseSnackMessageReturn } from '../hooks/useSnackMessage' ;
88import { CustomError , formatMessageValues } from './types/CustomError' ;
9+ import { NetworkTimeoutError } from './types/NetworkTimeoutError' ;
910
1011export type HeaderSnackInputs = Pick < SnackInputs , 'headerId' | 'headerTxt' | 'headerValues' > ;
1112
@@ -22,6 +23,13 @@ export function snackWithFallback(
2223 error : unknown ,
2324 headerInputs ?: HeaderSnackInputs
2425) {
26+ if ( error instanceof NetworkTimeoutError ) {
27+ snackError ( {
28+ messageId : error . message ,
29+ ...headerInputs ,
30+ } ) ;
31+ return ;
32+ }
2533 if ( error instanceof CustomError && error . businessErrorCode ) {
2634 snackError ( {
2735 messageId : error . businessErrorCode ,
Original file line number Diff line number Diff line change 1+ /**
2+ * Copyright (c) 2025, RTE (http://www.rte-france.com)
3+ * This Source Code Form is subject to the terms of the Mozilla Public
4+ * License, v. 2.0. If a copy of the MPL was not distributed with this
5+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+ */
7+
8+ /** Custom error type thrown when AbortSignal.timeout triggers. */
9+ export class NetworkTimeoutError extends Error {
10+ constructor ( messageKey : string = 'errors.network.timeout' ) {
11+ super ( messageKey ) ;
12+ this . name = 'NetworkTimeoutError' ;
13+ }
14+ }
Original file line number Diff line number Diff line change 55 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
66 */
77export * from './CustomError' ;
8+ export * from './NetworkTimeoutError' ;
89export * from './elementType' ;
910export * from './equipmentType' ;
1011export * from './equipmentTypes' ;
You can’t perform that action at this time.
0 commit comments