Skip to content

Commit f57f7f1

Browse files
committed
fix: fixed error view deployment bugs
This makes deployment actually possible now. Beta 12 is definitely getting yanked unfortunately!
1 parent d2a8377 commit f57f7f1

File tree

5 files changed

+37
-14
lines changed

5 files changed

+37
-14
lines changed

packages/perseus/src/client.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,18 @@ pub fn run_client<M: MutableStore, T: TranslationsManager>(
7272
}));
7373

7474
let plugins = app.plugins.clone();
75-
let error_views = app.error_views.clone();
75+
let error_views;
76+
#[cfg(debug_assertions)]
77+
{
78+
error_views = app.error_views.clone().unwrap_or_default();
79+
}
80+
#[cfg(not(debug_assertions))]
81+
{
82+
error_views = app
83+
.error_views
84+
.clone()
85+
.expect("you must provide your own error views in production");
86+
}
7687

7788
// This variable acts as a signal to determine whether or not there was a
7889
// show-stopping failure that should trigger root scope disposal

packages/perseus/src/init.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ pub struct PerseusAppBase<G: Html, M: MutableStore, T: TranslationsManager> {
116116
pub(crate) entities: EntityMap<G>,
117117
/// The app's error pages.
118118
#[cfg(client)]
119-
pub(crate) error_views: Rc<ErrorViews<G>>,
119+
pub(crate) error_views: Option<Rc<ErrorViews<G>>>,
120120
#[cfg(engine)]
121-
pub(crate) error_views: Arc<ErrorViews<G>>,
121+
pub(crate) error_views: Option<Arc<ErrorViews<G>>>,
122122
/// The maximum size for the page state store.
123123
pub(crate) pss_max_size: usize,
124124
/// The global state creator for the app.
@@ -337,7 +337,7 @@ impl<G: Html, M: MutableStore, T: TranslationsManager> PerseusAppBase<G, M, T> {
337337
entities: HashMap::new(),
338338
// We do offer default error views, but they'll panic if they're called for production
339339
// building
340-
error_views: Default::default(),
340+
error_views: None,
341341
pss_max_size: DFLT_PSS_MAX_SIZE,
342342
#[cfg(engine)]
343343
global_state_creator: Arc::new(GlobalStateCreator::default()),
@@ -386,7 +386,7 @@ impl<G: Html, M: MutableStore, T: TranslationsManager> PerseusAppBase<G, M, T> {
386386
entities: HashMap::new(),
387387
// We do offer default error pages, but they'll panic if they're called for production
388388
// building
389-
error_views: Default::default(),
389+
error_views: None,
390390
pss_max_size: DFLT_PSS_MAX_SIZE,
391391
// By default, we'll disable i18n (as much as I may want more websites to support more
392392
// languages...)
@@ -546,12 +546,12 @@ impl<G: Html, M: MutableStore, T: TranslationsManager> PerseusAppBase<G, M, T> {
546546
#[cfg(client)]
547547
{
548548
let panic_handler = val.take_panic_handler();
549-
self.error_views = Rc::new(val);
549+
self.error_views = Some(Rc::new(val));
550550
self.panic_handler_view = panic_handler;
551551
}
552552
#[cfg(engine)]
553553
{
554-
self.error_views = Arc::new(val);
554+
self.error_views = Some(Arc::new(val));
555555
}
556556

557557
self

packages/perseus/src/reactor/mod.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,12 @@ impl<G: Html, M: MutableStore, T: TranslationsManager> TryFrom<PerseusAppBase<G,
192192
entities: app.entities,
193193
locales,
194194
render_cfg,
195-
error_views: app.error_views,
195+
#[cfg(debug_assertions)]
196+
error_views: app.error_views.unwrap_or_default(),
197+
#[cfg(not(debug_assertions))]
198+
error_views: app
199+
.error_views
200+
.expect("you must provide your own error views in production"),
196201
root,
197202
})
198203
}

packages/perseus/src/turbine/mod.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,12 @@ impl<M: MutableStore, T: TranslationsManager> TryFrom<PerseusAppBase<SsrNode, M,
9898
root_id,
9999
static_dir: PathBuf::from(&app.static_dir),
100100
static_aliases,
101-
error_views: app.error_views,
101+
#[cfg(debug_assertions)]
102+
error_views: app.error_views.unwrap_or_default(),
103+
#[cfg(not(debug_assertions))]
104+
error_views: app
105+
.error_views
106+
.expect("you must provide your own error pages in production"),
102107
// This consumes the app
103108
// Note that we can't do anything in parallel with this anyway
104109
translations_manager: match app.translations_manager {

website/src/templates/comparisons.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -419,14 +419,16 @@ async fn get_build_state(
419419
serde_json::from_str::<RawComparison>(&contents).map_err(Error::from)?;
420420
let comparison_text = match raw_comparison.text.get(&locale) {
421421
Some(text) => text.to_string(),
422-
None => return Err(BlamedError {
423-
error: format!(
422+
None => {
423+
return Err(BlamedError {
424+
error: format!(
424425
"comparison {} does not have localized comparison text for locale {}",
425426
raw_comparison.name, locale
426427
)
427-
.into(),
428-
blame: ErrorBlame::Server(None),
429-
}),
428+
.into(),
429+
blame: ErrorBlame::Server(None),
430+
})
431+
}
430432
};
431433
let comparison = Comparison {
432434
name: raw_comparison.name,

0 commit comments

Comments
 (0)