MCPcopy Index your code
hub / github.com/ColmapView/Colmapview.github.io / classifyFetchError

Function classifyFetchError

src/utils/urlUtils.ts:43–91  ·  view source on GitHub ↗
(err: unknown, url?: string)

Source from the content-addressed store, hash-verified

41 * Classify error type from fetch error.
42 */
43export function classifyFetchError(err: unknown, url?: string): UrlLoadError {
44 if (err instanceof Error) {
45 // AbortError from timeout
46 if (err.name === 'AbortError') {
47 return {
48 type: 'timeout',
49 message: 'Request timed out',
50 details: `The request to ${url || 'the server'} took too long to respond.`,
51 failedFile: url,
52 };
53 }
54
55 // CORS errors typically appear as TypeError with network failure message
56 if (err.name === 'TypeError' && (
57 err.message.includes('Failed to fetch') ||
58 err.message.includes('NetworkError') ||
59 err.message.includes('CORS')
60 )) {
61 return {
62 type: 'cors',
63 message: 'Cross-origin request blocked',
64 details: 'This URL does not allow cross-origin requests. The server needs to include CORS headers.',
65 failedFile: url,
66 };
67 }
68
69 // Generic network error
70 if (err.name === 'TypeError') {
71 return {
72 type: 'network',
73 message: 'Network error',
74 details: err.message,
75 failedFile: url,
76 };
77 }
78
79 return {
80 type: 'unknown',
81 message: err.message,
82 failedFile: url,
83 };
84 }
85
86 return {
87 type: 'unknown',
88 message: String(err),
89 failedFile: url,
90 };
91}
92
93/**
94 * Create a File object from fetched blob.

Callers 3

fetchManifestColmapFilesFunction · 0.90
fetchSplatUrlFileFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected