From 44638f8c65c6bc89ceed518dced5f1f216ab2e13 Mon Sep 17 00:00:00 2001 From: Mats Sigge Date: Thu, 27 Jan 2022 21:14:48 +0100 Subject: [PATCH] Switch a few internal_error! to user_error! --- ast/src/module.rs | 8 ++++---- compiler/can/src/scope.rs | 4 ++-- editor/src/editor/main.rs | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ast/src/module.rs b/ast/src/module.rs index 91f53192a0d..4f70e873a66 100644 --- a/ast/src/module.rs +++ b/ast/src/module.rs @@ -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; @@ -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 ) @@ -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 diff --git a/compiler/can/src/scope.rs b/compiler/can/src/scope.rs index 69408bfcb0c..78837a6f9c8 100644 --- a/compiler/can/src/scope.rs +++ b/compiler/can/src/scope.rs @@ -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; @@ -196,7 +196,7 @@ impl Scope { } if !hidden.is_empty() { - internal_error!( + user_error!( "Found unbound type variables {:?} \n in type alias {:?} {:?} : {:?}", hidden, name, diff --git a/editor/src/editor/main.rs b/editor/src/editor/main.rs index 43a848fe8f8..3f7185a0e69 100644 --- a/editor/src/editor/main.rs +++ b/editor/src/editor/main.rs @@ -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; @@ -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, @@ -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, @@ -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,