mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 22:09:09 +00:00
separated markup and util crates, no more errors
This commit is contained in:
parent
ea62f15ac6
commit
f9e2e3469b
26 changed files with 1609 additions and 14 deletions
56
code_markup/src/markup_error.rs
Normal file
56
code_markup/src/markup_error.rs
Normal file
|
@ -0,0 +1,56 @@
|
|||
|
||||
use roc_utils::util_error::UtilError;
|
||||
use snafu::{Backtrace, NoneError, Snafu, ResultExt};
|
||||
|
||||
use crate::slow_pool::MarkNodeId;
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[snafu(visibility(pub))]
|
||||
pub enum MarkError {
|
||||
#[snafu(display(
|
||||
"CaretNotFound: No carets were found in the expected node with id {}",
|
||||
node_id
|
||||
))]
|
||||
CaretNotFound {
|
||||
node_id: MarkNodeId,
|
||||
backtrace: Backtrace,
|
||||
},
|
||||
#[snafu(display(
|
||||
"ExpectedTextNode: the function {} expected a Text node, got {} instead.",
|
||||
function_name,
|
||||
node_type
|
||||
))]
|
||||
ExpectedTextNode {
|
||||
function_name: String,
|
||||
node_type: String,
|
||||
backtrace: Backtrace,
|
||||
},
|
||||
#[snafu(display("NestedNodeMissingChild: expected to find child with id {} in Nested MarkupNode, but it was missing. Id's of the children are {:?}.", node_id, children_ids))]
|
||||
NestedNodeMissingChild {
|
||||
node_id: MarkNodeId,
|
||||
children_ids: Vec<MarkNodeId>,
|
||||
backtrace: Backtrace,
|
||||
},
|
||||
#[snafu(display(
|
||||
"NestedNodeRequired: required a Nested node at this position, node was a {}.",
|
||||
node_type
|
||||
))]
|
||||
NestedNodeRequired {
|
||||
node_type: String,
|
||||
backtrace: Backtrace,
|
||||
},
|
||||
#[snafu(display("UIError: {}", msg))]
|
||||
UtilErrorBacktrace { msg: String, backtrace: Backtrace },
|
||||
}
|
||||
|
||||
pub type MarkResult<T, E = MarkError> = std::result::Result<T, E>;
|
||||
|
||||
impl From<UtilError> for MarkError {
|
||||
fn from(util_err: UtilError) -> Self {
|
||||
let msg = format!("{}", util_err);
|
||||
|
||||
// hack to handle MarkError derive
|
||||
let dummy_res: Result<(), NoneError> = Err(NoneError {});
|
||||
dummy_res.context(UtilErrorBacktrace { msg }).unwrap_err()
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue