Skip to content

Commit

Permalink
feat: made static generation errors display causes
Browse files Browse the repository at this point in the history
Fixes #101.
  • Loading branch information
arctic-hen7 committed Dec 30, 2021
1 parent 7c9fb4a commit ab7742a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
1 change: 1 addition & 0 deletions examples/basic/.perseus/builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ perseus = { path = "../../../../packages/perseus", features = [ "tinker-plugins"
futures = "0.3"
fs_extra = "1"
tokio = { version = "1", features = [ "macros", "rt-multi-thread" ] }
fmterr = "0.1"

# We define a binary for building, serving, and doing both
[[bin]]
Expand Down
3 changes: 2 additions & 1 deletion examples/basic/.perseus/builder/src/bin/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use fmterr::fmt_err;
use perseus::{internal::build::build_app, PluginAction, SsrNode};
use perseus_engine::app::{
get_immutable_store, get_locales, get_mutable_store, get_plugins, get_templates_map,
Expand Down Expand Up @@ -40,7 +41,7 @@ async fn real_main() -> i32 {
)
.await;
if let Err(err) = res {
let err_msg = format!("Static generation failed: '{}'.", &err);
let err_msg = fmt_err(&err);
plugins
.functional_actions
.build_actions
Expand Down
18 changes: 8 additions & 10 deletions examples/basic/.perseus/builder/src/bin/export.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use fmterr::fmt_err;
use fs_extra::dir::{copy as copy_dir, CopyOptions};
use perseus::{
internal::{build::build_app, export::export_app, get_path_prefix_server},
Expand Down Expand Up @@ -71,7 +72,7 @@ async fn build_and_export() -> i32 {
)
.await;
if let Err(err) = build_res {
let err_msg = format!("Static exporting failed: '{}'.", &err);
let err_msg = fmt_err(&err);
plugins
.functional_actions
.export_actions
Expand Down Expand Up @@ -99,7 +100,7 @@ async fn build_and_export() -> i32 {
)
.await;
if let Err(err) = export_res {
let err_msg = format!("Static exporting failed: '{}'.", &err);
let err_msg = fmt_err(&err);
plugins
.functional_actions
.export_actions
Expand All @@ -125,10 +126,10 @@ fn copy_static_dir() -> i32 {
if from.is_dir() {
if let Err(err) = copy_dir(&from, &to, &CopyOptions::new()) {
let err_msg = format!(
"Static exporting failed: 'couldn't copy static alias directory from '{}' to '{}': '{}''",
"couldn't copy static alias directory from '{}' to '{}': '{}'",
from.to_str().map(|s| s.to_string()).unwrap(),
to,
err.to_string()
fmt_err(&err)
);
plugins
.functional_actions
Expand All @@ -140,10 +141,10 @@ fn copy_static_dir() -> i32 {
}
} else if let Err(err) = fs::copy(&from, &to) {
let err_msg = format!(
"Static exporting failed: 'couldn't copy static alias file from '{}' to '{}': '{}''",
"couldn't copy static alias file from '{}' to '{}': '{}'",
from.to_str().map(|s| s.to_string()).unwrap(),
to,
err.to_string()
fmt_err(&err)
);
plugins
.functional_actions
Expand All @@ -165,10 +166,7 @@ fn copy_static_aliases() -> i32 {
let static_dir = PathBuf::from("../static");
if static_dir.exists() {
if let Err(err) = copy_dir(&static_dir, "dist/exported/.perseus/", &CopyOptions::new()) {
let err_msg = format!(
"Static exporting failed: 'couldn't copy static directory: '{}''",
&err
);
let err_msg = format!("couldn't copy static directory: '{}'", fmt_err(&err));
plugins
.functional_actions
.export_actions
Expand Down

0 comments on commit ab7742a

Please sign in to comment.