( url: string, fetchImpl: FetchUrl = fetchWithTimeout )
| 42 | } |
| 43 | |
| 44 | export async function fetchSplatUrlFile( |
| 45 | url: string, |
| 46 | fetchImpl: FetchUrl = fetchWithTimeout |
| 47 | ): Promise<File> { |
| 48 | try { |
| 49 | const response = await fetchImpl(url); |
| 50 | if (!response.ok) { |
| 51 | const error: UrlLoadError = { |
| 52 | type: response.status === 404 ? 'not_found' : 'network', |
| 53 | message: `Failed to fetch splat (${response.status})`, |
| 54 | details: response.statusText, |
| 55 | failedFile: url, |
| 56 | }; |
| 57 | throw error; |
| 58 | } |
| 59 | |
| 60 | const blob = await response.blob(); |
| 61 | return blobToFile(blob, getFilenameFromUrl(url)); |
| 62 | } catch (error) { |
| 63 | if (isUrlLoadError(error)) { |
| 64 | throw error; |
| 65 | } |
| 66 | throw classifyFetchError(error, url); |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | export async function loadSplatUrlSource( |
| 71 | url: string, |
no test coverage detected