ocypode_lang/diagnostics/runtime/
mod.rs

1pub mod functions;
2pub mod idents;
3pub mod types;
4use miette::{Diagnostic, NamedSource};
5
6/// Already declared error diagnostic.
7#[derive(Debug, Diagnostic, thiserror::Error)]
8#[diagnostic(
9    code("Error(runtime::already_declared)"),
10    help("Try renaming `{name}` or removing the previous declaration.")
11)]
12#[error("Identifier already declared")]
13pub struct AlreadyDeclared {
14    pub(crate) name: String,
15    #[source_code]
16    pub(crate) src: NamedSource,
17    #[label("Identifier `{name}` already declared here")]
18    pub(crate) old_decl: miette::SourceSpan,
19    #[label("And you tried to declare it again here")]
20    pub(crate) new_decl: miette::SourceSpan,
21}
22
23/// Format error diagnostic.
24#[derive(Debug, Diagnostic, thiserror::Error)]
25#[diagnostic(code("Error(runtime::format)"), help("{help_message}"))]
26#[error("Format error")]
27pub struct FormatError {
28    pub(crate) reason: String,
29    pub(crate) help_message: String,
30    #[source_code]
31    pub(crate) src: NamedSource,
32    #[label("{reason}")]
33    pub(crate) span: miette::SourceSpan,
34}
35
36/// Invalid unpaked argument
37#[derive(Debug, Diagnostic, thiserror::Error)]
38#[diagnostic(
39    code("Error(runtime::invalid_unpacked_argument)"),
40    help("Try using an array instead of `{type_name}`.")
41)]
42#[error("Invalid unpacked argument")]
43pub struct InvalidUnpackedArgument {
44    pub(crate) type_name: String,
45    #[source_code]
46    pub(crate) src: NamedSource,
47    #[label("cannot unpack `{type_name}` type")]
48    pub(crate) span: miette::SourceSpan,
49}
50
51/// Runtime error diagnostic.
52#[derive(Debug, Diagnostic, thiserror::Error)]
53#[diagnostic(code("Error(runtime::runtime)"))]
54#[error("Runtime error")]
55pub struct RuntimeError {
56    pub(crate) reason: String,
57    #[source_code]
58    pub(crate) src: NamedSource,
59    #[label("{reason}")]
60    pub(crate) span: miette::SourceSpan,
61}