Skip to content

Commit

Permalink
Switch a few internal_error! to user_error!
Browse files Browse the repository at this point in the history
  • Loading branch information
matssigge committed Jan 27, 2022
1 parent 807c8ca commit 44638f8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions ast/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::path::Path;

use bumpalo::Bump;
use roc_collections::all::MutMap;
use roc_error_macros::internal_error;
use roc_error_macros::user_error;
use roc_load::file::LoadedModule;
use roc_target::TargetInfo;

Expand All @@ -15,7 +15,7 @@ pub fn load_module(src_file: &Path) -> LoadedModule {
src_file.to_path_buf(),
arena.alloc(roc_builtins::std::standard_stdlib()),
src_file.parent().unwrap_or_else(|| {
internal_error!(
user_error!(
"src_file {:?} did not have a parent directory but I need to have one.",
src_file
)
Expand All @@ -28,13 +28,13 @@ pub fn load_module(src_file: &Path) -> LoadedModule {
match loaded {
Ok(x) => x,
Err(roc_load::file::LoadingProblem::FormattedReport(report)) => {
internal_error!(
user_error!(
"Failed to load module from src_file {:?}. Report: {:?}",
src_file,
report
);
}
Err(e) => internal_error!(
Err(e) => user_error!(
"Failed to load module from src_file {:?}: {:?}",
src_file,
e
Expand Down
4 changes: 2 additions & 2 deletions compiler/can/src/scope.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use roc_collections::all::{MutSet, SendMap};
use roc_error_macros::internal_error;
use roc_error_macros::user_error;
use roc_module::ident::{Ident, Lowercase};
use roc_module::symbol::{IdentIds, ModuleId, Symbol};
use roc_problem::can::RuntimeError;
Expand Down Expand Up @@ -196,7 +196,7 @@ impl Scope {
}

if !hidden.is_empty() {
internal_error!(
user_error!(
"Found unbound type variables {:?} \n in type alias {:?} {:?} : {:?}",
hidden,
name,
Expand Down
12 changes: 6 additions & 6 deletions editor/src/editor/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use pipelines::RectResources;
use roc_ast::lang::env::Env;
use roc_ast::mem_pool::pool::Pool;
use roc_ast::module::load_module;
use roc_error_macros::internal_error;
use roc_error_macros::{internal_error, user_error};
use roc_module::symbol::IdentIds;
use roc_types::subs::VarStore;
use std::collections::HashSet;
Expand Down Expand Up @@ -514,11 +514,11 @@ fn init_new_roc_project(project_dir_path_str: &str) -> (PathStr, String) {
fn create_roc_file_if_not_exists(project_dir_path: &Path, roc_file_path: &Path) -> String {
if !roc_file_path.exists() {
let mut roc_file = File::create(roc_file_path).unwrap_or_else(|err| {
internal_error!("No roc file path was passed to the editor, so I wanted to create a new roc project with the file {:?}, but it failed: {}", roc_file_path, err)
user_error!("No roc file path was passed to the editor, so I wanted to create a new roc project with the file {:?}, but it failed: {}", roc_file_path, err)
});

write!(roc_file, "{}", HELLO_WORLD).unwrap_or_else(|err| {
internal_error!(
user_error!(
r#"No roc file path was passed to the editor, so I created a new roc project with the file {:?}
I wanted to write roc hello world to that file, but it failed: {:?}"#,
roc_file_path,
Expand All @@ -529,7 +529,7 @@ fn create_roc_file_if_not_exists(project_dir_path: &Path, roc_file_path: &Path)
HELLO_WORLD.to_string()
} else {
std::fs::read_to_string(roc_file_path).unwrap_or_else(|err| {
internal_error!(
user_error!(
"I detected an existing {:?} inside {:?}, but I failed to read from it: {}",
roc_file_path,
project_dir_path,
Expand All @@ -545,14 +545,14 @@ fn copy_roc_platform_if_not_exists(
project_dir_path: &Path,
) {
if !orig_platform_path.exists() && !project_platform_path.exists() {
internal_error!(
user_error!(
r#"No roc file path was passed to the editor, I wanted to create a new roc project but I could not find the platform at {:?}.
Are you at the root of the roc repository?"#,
orig_platform_path
);
} else if !project_platform_path.exists() {
copy(orig_platform_path, project_dir_path, &CopyOptions::new()).unwrap_or_else(|err|{
internal_error!(r#"No roc file path was passed to the editor, so I wanted to create a new roc project and roc projects require a platform,
user_error!(r#"No roc file path was passed to the editor, so I wanted to create a new roc project and roc projects require a platform,
I tried to copy the platform at {:?} to {:?} but it failed: {}"#,
orig_platform_path,
project_platform_path,
Expand Down

0 comments on commit 44638f8

Please sign in to comment.