Bonjour
J 'utilise en Angular13 un GlobalError Handler, mais en plus de l' URL qui pose soucis j 'aurais bien aimé avoir le nom de la méthode appelé, es ce possible ?
Merci
J' ai essayé également de bypasser le GlobalError Handler sans succes dans certains cas afin de pouvoir rajouter un message spécifique
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 export class GlobalErrorHandler implements ErrorHandler { constructor( private errorService: ErrorService, private logService: LogService) {} handleError(error) { // const stack = environment.production ? null : Error().stack; console.log('Global'); // IMPORTANT: Rethrow the error otherwise it gets swallowed throw error; } } export class AppComponent { private apiUrl = 'https://localhost:8080/api/ZZZZusers'; constructor(private http2: HttpClient) {} getHttpError2() { console.log('OK ICI'); return this.http2.get(this.apiUrl).pipe( retry(1), catchError(this.handleError('mon MESSAGE', []))); console.log('JAMAIS ICI'); } private handleError < T > (operation = 'operation', result ? : T) { return (error: any): Observable < T > => { console.log('DANS HANDLER AIE JAMAIS ON Y PASSE'); return of(result as T); }; } }
Partager