1mod catch_unwind;
2mod convert;
3mod diagnostic;
4mod error;
5mod ext;
6pub(crate) mod graphical;
7pub(crate) mod miette_helpers;
8pub use catch_unwind::*;
9pub use diagnostic::*;
10pub use error::*;
11pub use ext::*;
12pub mod emitter;
13pub use convert::*;
14
15mod macros;
16
17pub use miette;
18pub use thiserror;
19
20pub type Error = miette::Error;
21
22pub type Result<T, E = miette::Error> = std::result::Result<T, E>;
23
24#[derive(Debug)]
27pub struct TWithDiagnosticArray<T: std::fmt::Debug> {
28 pub inner: T,
29 pub diagnostic: Vec<Diagnostic>,
30}
31
32impl<T: std::fmt::Debug> TWithDiagnosticArray<T> {
33 pub fn new(inner: T, diagnostic: Vec<Diagnostic>) -> Self {
34 Self { inner, diagnostic }
35 }
36
37 pub fn diagnostics(&self) -> &Vec<Diagnostic> {
38 &self.diagnostic
39 }
40
41 pub fn take_inner(self) -> T {
42 self.inner
43 }
44
45 pub fn split_into_parts(self) -> (T, Vec<Diagnostic>) {
46 (self.inner, self.diagnostic)
47 }
48
49 pub fn get(&self) -> &T {
50 &self.inner
51 }
52}
53
54impl<T: Clone + std::fmt::Debug> Clone for TWithDiagnosticArray<T> {
55 fn clone(&self) -> Self {
56 Self {
57 inner: self.inner.clone(),
58 diagnostic: self.diagnostic.clone(),
59 }
60 }
61}
62
63pub trait IntoTWithDiagnosticArray {
65 fn with_diagnostic(self, diagnostic: Vec<Diagnostic>) -> TWithDiagnosticArray<Self>
66 where
67 Self: Sized + std::fmt::Debug;
68
69 fn with_empty_diagnostic(self) -> TWithDiagnosticArray<Self>
70 where
71 Self: Sized + std::fmt::Debug,
72 {
73 TWithDiagnosticArray {
74 inner: self,
75 diagnostic: vec![],
76 }
77 }
78}
79
80impl<T: Sized + std::fmt::Debug> IntoTWithDiagnosticArray for T {
81 fn with_diagnostic(self, diagnostic: Vec<Diagnostic>) -> TWithDiagnosticArray<Self>
82 where
83 Self: Sized + std::fmt::Debug,
84 {
85 TWithDiagnosticArray {
86 inner: self,
87 diagnostic,
88 }
89 }
90}
91
92#[doc(hidden)]
93pub mod __private {
94 pub use core::result::Result::Err;
95
96 pub use miette::{Severity, miette};
97
98 pub use crate::{diagnostic::Severity as RspackSeverity, error, error::InternalError};
99}