gpt-engineer-app[bot] commited on
Commit
e22144c
·
1 Parent(s): ac6e1c8
Files changed (1) hide show
  1. src/components/upload-dialog.tsx +11 -2
src/components/upload-dialog.tsx CHANGED
@@ -75,10 +75,10 @@ export function UploadDialog({ onCreated }: { onCreated?: (id: string) => void }
75
  await analyze({ data: { incidentId: inc.id } });
76
  toast.success("Analysis complete");
77
  } catch (e: any) {
78
- toast.error(`Analysis failed: ${e.message}`);
79
  }
80
  } catch (e: any) {
81
- toast.error(e.message);
82
  } finally { setBusy(false); }
83
  };
84
 
@@ -139,3 +139,12 @@ export function UploadDialog({ onCreated }: { onCreated?: (id: string) => void }
139
  </Dialog>
140
  );
141
  }
 
 
 
 
 
 
 
 
 
 
75
  await analyze({ data: { incidentId: inc.id } });
76
  toast.success("Analysis complete");
77
  } catch (e: any) {
78
+ toast.error(`Analysis failed: ${await getErrorMessage(e, "Analysis request failed")}`);
79
  }
80
  } catch (e: any) {
81
+ toast.error(await getErrorMessage(e, "Request failed"));
82
  } finally { setBusy(false); }
83
  };
84
 
 
139
  </Dialog>
140
  );
141
  }
142
+
143
+ async function getErrorMessage(error: unknown, fallback: string) {
144
+ if (error instanceof Response) {
145
+ return `${error.status} ${await error.text().catch(() => error.statusText || fallback)}`;
146
+ }
147
+
148
+ const message = (error as { message?: string } | null)?.message;
149
+ return message && message !== "[object Response]" ? message : fallback;
150
+ }