| 269 | const err = new Error('Load aborted'); |
| 270 | err.thumbnailLoadAborted = true; |
| 271 | throw err; |
| 272 | } |
| 273 | |
| 274 | const ipcBuf = await tryIpc(); |
| 275 | if (ipcBuf && ipcBuf.byteLength > 0) return ipcBuf; |
| 276 | throw new Error('Cannot read model file'); |
| 277 | } |
| 278 | |
| 279 | window.loadLibraryFileBuffer = loadLibraryFileBuffer; |
| 280 | |
| 281 | function formatUserFacingPreviewError(error) { |
| 282 | let message = error?.message || String(error || 'Unknown error'); |
| 283 | const ipcMatch = message.match(/Error invoking remote method 'parse-3mf-preview':\s*(?:Error:\s*)?([\s\S]+)/); |
| 284 | if (ipcMatch) { |
| 285 | message = ipcMatch[1].trim(); |
| 286 | } else if (message.startsWith('Error: ')) { |
| 287 | message = message.slice(7); |
| 288 | } |
| 289 | if (message.includes('ERR_WORKER_OUT_OF_MEMORY') || message.includes('heap out of memory')) { |
| 290 | return 'Preview ran out of memory while processing this model. Try closing other previews first, or restart the app.'; |
| 291 | } |