parseApiError.tsx 369 B

12345678910111213141516
  1. import {ResponseMeta} from 'sentry/api';
  2. export default function parseApiError(resp: ResponseMeta): string {
  3. const {detail} = (resp && resp.responseJSON) || ({} as object);
  4. // return immediately if string
  5. if (typeof detail === 'string') {
  6. return detail;
  7. }
  8. if (detail && detail.message) {
  9. return detail.message;
  10. }
  11. return 'Unknown API Error';
  12. }