Skip to content

Commit 3f1890a

Browse files
add d2c exception safety on prod
1 parent a6dae9e commit 3f1890a

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

editor/scaffolds/editor/editor.tsx

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ import { EditorSkeleton } from "./skeleton";
3333
import { colors } from "theme";
3434
import Link from "next/link";
3535

36+
const _ignore_d2c_errors_on_prod = (e) => {
37+
if (process.env.NODE_ENV === "production") {
38+
return;
39+
}
40+
throw e;
41+
};
42+
3643
export function Editor() {
3744
const router = useRouter();
3845
const wstate = useWorkspaceState();
@@ -135,7 +142,9 @@ export function Editor() {
135142
framework: framework_config,
136143
asset_config: { skip_asset_replacement: true },
137144
build_config: build_config,
138-
}).then(on_result);
145+
})
146+
.then(on_result)
147+
.catch(_ignore_d2c_errors_on_prod);
139148

140149
// build final code with asset fetch
141150
if (!MainImageRepository.instance.empty) {
@@ -144,7 +153,9 @@ export function Editor() {
144153
framework: framework_config,
145154
asset_config: { asset_repository: MainImageRepository.instance },
146155
build_config: build_config,
147-
}).then(on_result);
156+
})
157+
.then(on_result)
158+
.catch(_ignore_d2c_errors_on_prod);
148159
}
149160
}
150161
}, [targetted?.id, framework_config?.framework]);
@@ -177,15 +188,19 @@ export function Editor() {
177188
"https://bridged-service-static.s3.us-west-1.amazonaws.com/placeholder-images/image-placeholder-bw-tile-100.png",
178189
},
179190
},
180-
}).then(on_preview_result);
191+
})
192+
.then(on_preview_result)
193+
.catch(_ignore_d2c_errors_on_prod);
181194

182195
if (!MainImageRepository.instance.empty) {
183196
designToCode({
184197
input: root,
185198
build_config: build_config,
186199
framework: vanilla_presets.vanilla_default,
187200
asset_config: { asset_repository: MainImageRepository.instance },
188-
}).then(on_preview_result);
201+
})
202+
.then(on_preview_result)
203+
.catch(_ignore_d2c_errors_on_prod);
189204
}
190205
}
191206
},

0 commit comments

Comments
 (0)