Skip to content

Commit

Permalink
fix: fixed error view deployment bugs
Browse files Browse the repository at this point in the history
This makes deployment actually possible now. Beta 12 is definitely
getting yanked unfortunately!
  • Loading branch information
arctic-hen7 committed Jan 2, 2023
1 parent d2a8377 commit f57f7f1
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 14 deletions.
13 changes: 12 additions & 1 deletion packages/perseus/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,18 @@ pub fn run_client<M: MutableStore, T: TranslationsManager>(
}));

let plugins = app.plugins.clone();
let error_views = app.error_views.clone();
let error_views;
#[cfg(debug_assertions)]
{
error_views = app.error_views.clone().unwrap_or_default();
}
#[cfg(not(debug_assertions))]
{
error_views = app
.error_views
.clone()
.expect("you must provide your own error views in production");
}

// This variable acts as a signal to determine whether or not there was a
// show-stopping failure that should trigger root scope disposal
Expand Down
12 changes: 6 additions & 6 deletions packages/perseus/src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ pub struct PerseusAppBase<G: Html, M: MutableStore, T: TranslationsManager> {
pub(crate) entities: EntityMap<G>,
/// The app's error pages.
#[cfg(client)]
pub(crate) error_views: Rc<ErrorViews<G>>,
pub(crate) error_views: Option<Rc<ErrorViews<G>>>,
#[cfg(engine)]
pub(crate) error_views: Arc<ErrorViews<G>>,
pub(crate) error_views: Option<Arc<ErrorViews<G>>>,
/// The maximum size for the page state store.
pub(crate) pss_max_size: usize,
/// The global state creator for the app.
Expand Down Expand Up @@ -337,7 +337,7 @@ impl<G: Html, M: MutableStore, T: TranslationsManager> PerseusAppBase<G, M, T> {
entities: HashMap::new(),
// We do offer default error views, but they'll panic if they're called for production
// building
error_views: Default::default(),
error_views: None,
pss_max_size: DFLT_PSS_MAX_SIZE,
#[cfg(engine)]
global_state_creator: Arc::new(GlobalStateCreator::default()),
Expand Down Expand Up @@ -386,7 +386,7 @@ impl<G: Html, M: MutableStore, T: TranslationsManager> PerseusAppBase<G, M, T> {
entities: HashMap::new(),
// We do offer default error pages, but they'll panic if they're called for production
// building
error_views: Default::default(),
error_views: None,
pss_max_size: DFLT_PSS_MAX_SIZE,
// By default, we'll disable i18n (as much as I may want more websites to support more
// languages...)
Expand Down Expand Up @@ -546,12 +546,12 @@ impl<G: Html, M: MutableStore, T: TranslationsManager> PerseusAppBase<G, M, T> {
#[cfg(client)]
{
let panic_handler = val.take_panic_handler();
self.error_views = Rc::new(val);
self.error_views = Some(Rc::new(val));
self.panic_handler_view = panic_handler;
}
#[cfg(engine)]
{
self.error_views = Arc::new(val);
self.error_views = Some(Arc::new(val));
}

self
Expand Down
7 changes: 6 additions & 1 deletion packages/perseus/src/reactor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,12 @@ impl<G: Html, M: MutableStore, T: TranslationsManager> TryFrom<PerseusAppBase<G,
entities: app.entities,
locales,
render_cfg,
error_views: app.error_views,
#[cfg(debug_assertions)]
error_views: app.error_views.unwrap_or_default(),
#[cfg(not(debug_assertions))]
error_views: app
.error_views
.expect("you must provide your own error views in production"),
root,
})
}
Expand Down
7 changes: 6 additions & 1 deletion packages/perseus/src/turbine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,12 @@ impl<M: MutableStore, T: TranslationsManager> TryFrom<PerseusAppBase<SsrNode, M,
root_id,
static_dir: PathBuf::from(&app.static_dir),
static_aliases,
error_views: app.error_views,
#[cfg(debug_assertions)]
error_views: app.error_views.unwrap_or_default(),
#[cfg(not(debug_assertions))]
error_views: app
.error_views
.expect("you must provide your own error pages in production"),
// This consumes the app
// Note that we can't do anything in parallel with this anyway
translations_manager: match app.translations_manager {
Expand Down
12 changes: 7 additions & 5 deletions website/src/templates/comparisons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,14 +419,16 @@ async fn get_build_state(
serde_json::from_str::<RawComparison>(&contents).map_err(Error::from)?;
let comparison_text = match raw_comparison.text.get(&locale) {
Some(text) => text.to_string(),
None => return Err(BlamedError {
error: format!(
None => {
return Err(BlamedError {
error: format!(
"comparison {} does not have localized comparison text for locale {}",
raw_comparison.name, locale
)
.into(),
blame: ErrorBlame::Server(None),
}),
.into(),
blame: ErrorBlame::Server(None),
})
}
};
let comparison = Comparison {
name: raw_comparison.name,
Expand Down

0 comments on commit f57f7f1

Please sign in to comment.