[TIL] Promise 에서 에러 Sentry로 보내기 (Expo)

햄스터아저씨·2021년 7월 24일
0

Promise에서 catch 를 처리할 경우 throw new Error를 한다고 해도 sentry로 에러가 송신되지 않는다.
Promise에서 catch 를 통해 reject 핸들러가 동작해서 "처리" 했다고 판단되기 때문.
따라서 이 경우, 아래와 같이 Sentry.Native.captureException를 통해 에러를 직접 보내야 한다.

import * as Sentry from "sentry-expo";

...

FileSystem.deleteAsync(...)
  .then(() => {
  	...
  })
  .catch((e) => {
  	Sentry.Native.captureException(new Error(`Fali delete a room: ${e}`));
  });

참고
https://ko.javascript.info/promise-error-handling

profile
서버도 하고 웹도 하고 시스템이나 인프라나 네트워크나 그냥 다 함.

0개의 댓글