react-native-exception-handler icon indicating copy to clipboard operation
react-native-exception-handler copied to clipboard

JS error from Async function becomes undefined when it is catched

Open realradical opened this issue 5 years ago • 1 comments
trafficstars

I use setJSExceptionHandler. My code has some loading logic using an async function. When my server is down, it supposes to throw an error. My catch block actually logs network error to the console, but this exception handler can't get the error context, always complaining it is undefined. I suspect it has something to do with the nature of async function. Any idea? image

`const _appLoadingAsync = async () => { try { const refreshToken = await SecureStore.getItemAsync('refreshToken'); let authToken = null; if (refreshToken !== null) { const config = { headers: { Authorization: Bearer ${refreshToken} }, }; const response = await axiosBase.put( '/auth/refresh_token', null, config ); authToken = response.data.authToken; }

  dispatch({ type: ActionType.RestoreToken, token: authToken });
} catch (e) {
  // tslint:disable-next-line: no-console
  console.log(e);
  throw new Error('my error');
}

};`

realradical avatar Feb 18 '20 03:02 realradical

Has this been resolved, yet? Displaying network errors is the only reason, I wanted to use this library :(

FinnGu avatar May 29 '21 16:05 FinnGu