(
response: DataFetcherResponse<T> | Promise<DataFetcherResponse<T>>
)
| 18 | export function throwIfDataError<T>(response: DataFetcherResponse<T>): T; |
| 19 | export function throwIfDataError<T>(response: Promise<DataFetcherResponse<T>>): Promise<T>; |
| 20 | export function throwIfDataError<T>( |
| 21 | response: DataFetcherResponse<T> | Promise<DataFetcherResponse<T>> |
| 22 | ): T | Promise<T> { |
| 23 | if (response instanceof Promise) { |
| 24 | return response.then((result) => throwIfDataError(result)); |
| 25 | } |
| 26 | |
| 27 | if (response.error) { |
| 28 | throw new DataFetcherError(response.error.message, response.error.code); |
| 29 | } |
| 30 | return response.data; |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Get the data from the response or null if there is an "Not found" error. |
no outgoing calls
no test coverage detected