mirror of
https://github.com/hanzoai/sentinel.git
synced 2026-09-29 22:34:33 +00:00
17 lines
356 B
TypeScript
17 lines
356 B
TypeScript
import type {ResponseMeta} from 'sentry/api';
|
|
|
|
export default function parseApiError(resp: ResponseMeta): string {
|
|
const {detail} = resp?.responseJSON || ({} as object);
|
|
|
|
// return immediately if string
|
|
if (typeof detail === 'string') {
|
|
return detail;
|
|
}
|
|
|
|
if (detail?.message) {
|
|
return detail.message;
|
|
}
|
|
|
|
return 'Unknown API Error';
|
|
}
|