diff --git a/server/index.js b/server/index.js
index 5747e95d..dae9575d 100644
--- a/server/index.js
+++ b/server/index.js
@@ -111,6 +111,10 @@ CRITICAL: content_svg MUST be a string with single quotes in SVG attributes. Pat
const jsonStr = text.replace(/```json/g, '').replace(/```/g, '').trim();
const data = JSON.parse(jsonStr);
+ if (!data.title || !data.sections || !Array.isArray(data.sections)) {
+ throw new Error('Invalid generation format');
+ }
+
res.json(data);
} catch (error) {
console.error('Generation error:', error);
diff --git a/src/App.jsx b/src/App.jsx
index 3e114cd4..64db2b45 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -11,9 +11,11 @@ function App() {
const [isGenerating, setIsGenerating] = React.useState(false);
const [history, setHistory] = React.useState([]);
+ const [error, setError] = React.useState(null);
const handleGenerate = async (data) => {
setIsGenerating(true);
+ setError(null);
try {
const response = await fetch('/api/generate', {
method: 'POST',
@@ -40,7 +42,7 @@ function App() {
} catch (error) {
console.error("Error generating sheet:", error);
- // Optional: Show error state
+ setError(error.message || "Failed to generate sheet. Please try again.");
} finally {
setIsGenerating(false);
}
@@ -75,6 +77,11 @@ function App() {
{/* Main Content */}