tree_sitter_facade_sg/
error.rs

1#[cfg(not(target_arch = "wasm32"))]
2mod native {
3    #[derive(Eq, PartialEq)]
4    pub struct IncludedRangesError {
5        pub(crate) inner: tree_sitter::IncludedRangesError,
6    }
7
8    impl std::fmt::Debug for IncludedRangesError {
9        fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
10            std::fmt::Debug::fmt(&self.inner, fmt)
11        }
12    }
13
14    impl std::fmt::Display for IncludedRangesError {
15        fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
16            write!(fmt, "{:?}", self.inner)
17        }
18    }
19
20    impl std::error::Error for IncludedRangesError {
21    }
22
23    impl From<tree_sitter::IncludedRangesError> for IncludedRangesError {
24        #[inline]
25        fn from(inner: tree_sitter::IncludedRangesError) -> Self {
26            Self { inner }
27        }
28    }
29
30    unsafe impl Send for IncludedRangesError {
31    }
32
33    unsafe impl Sync for IncludedRangesError {
34    }
35
36    #[derive(Eq, PartialEq)]
37    pub struct QueryError {
38        pub(crate) inner: tree_sitter::QueryError,
39    }
40
41    impl std::fmt::Debug for QueryError {
42        fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
43            std::fmt::Debug::fmt(&self.inner, fmt)
44        }
45    }
46
47    impl std::fmt::Display for QueryError {
48        fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
49            write!(fmt, "{:?}", self.inner)
50        }
51    }
52
53    impl std::error::Error for QueryError {
54    }
55
56    impl From<tree_sitter::QueryError> for QueryError {
57        #[inline]
58        fn from(inner: tree_sitter::QueryError) -> Self {
59            Self { inner }
60        }
61    }
62
63    unsafe impl Send for QueryError {
64    }
65
66    unsafe impl Sync for QueryError {
67    }
68
69    #[derive(Eq, PartialEq)]
70    pub struct LanguageError {
71        pub(crate) inner: tree_sitter::LanguageError,
72    }
73
74    impl std::fmt::Debug for LanguageError {
75        fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
76            std::fmt::Debug::fmt(&self.inner, fmt)
77        }
78    }
79
80    impl std::fmt::Display for LanguageError {
81        fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
82            std::fmt::Display::fmt(&self.inner, fmt)
83        }
84    }
85
86    impl std::error::Error for LanguageError {
87    }
88
89    impl From<tree_sitter::LanguageError> for LanguageError {
90        #[inline]
91        fn from(inner: tree_sitter::LanguageError) -> Self {
92            Self { inner }
93        }
94    }
95
96    unsafe impl Send for LanguageError {
97    }
98
99    unsafe impl Sync for LanguageError {
100    }
101
102    #[derive(Eq, PartialEq)]
103    pub struct ParserError {
104        pub(crate) inner: std::convert::Infallible,
105    }
106
107    impl std::fmt::Debug for ParserError {
108        fn fmt(&self, _fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
109            unreachable!()
110        }
111    }
112
113    impl std::fmt::Display for ParserError {
114        fn fmt(&self, _fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
115            unreachable!()
116        }
117    }
118
119    impl std::error::Error for ParserError {
120    }
121
122    unsafe impl Send for ParserError {
123    }
124
125    unsafe impl Sync for ParserError {
126    }
127}
128
129#[cfg(not(target_arch = "wasm32"))]
130pub use native::*;
131
132#[cfg(target_arch = "wasm32")]
133mod wasm {
134    #[derive(Eq, PartialEq)]
135    pub struct IncludedRangesError {
136        pub(crate) inner: js_sys::Error,
137    }
138
139    unsafe impl Send for IncludedRangesError {
140    }
141
142    unsafe impl Sync for IncludedRangesError {
143    }
144
145    impl std::fmt::Debug for IncludedRangesError {
146        fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
147            std::fmt::Debug::fmt(&self.inner, fmt)
148        }
149    }
150
151    impl std::fmt::Display for IncludedRangesError {
152        fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
153            fmt.write_str(&<_ as Into<String>>::into(self.inner.message()))
154        }
155    }
156
157    impl std::error::Error for IncludedRangesError {
158    }
159
160    impl From<js_sys::Error> for IncludedRangesError {
161        #[inline]
162        fn from(inner: js_sys::Error) -> Self {
163            Self { inner }
164        }
165    }
166
167    #[derive(Eq, PartialEq)]
168    pub struct LanguageError {
169        pub(crate) inner: web_tree_sitter_sg::LanguageError,
170    }
171
172    unsafe impl Send for LanguageError {
173    }
174
175    unsafe impl Sync for LanguageError {
176    }
177
178    impl std::fmt::Debug for LanguageError {
179        fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
180            std::fmt::Debug::fmt(&self.inner, fmt)
181        }
182    }
183
184    impl std::fmt::Display for LanguageError {
185        fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
186            fmt.write_str(&<_ as Into<String>>::into(self.inner.message()))
187        }
188    }
189
190    impl std::error::Error for LanguageError {
191    }
192
193    impl From<web_tree_sitter_sg::LanguageError> for LanguageError {
194        #[inline]
195        fn from(inner: web_tree_sitter_sg::LanguageError) -> Self {
196            Self { inner }
197        }
198    }
199
200    #[derive(Eq, PartialEq)]
201    pub struct ParserError {
202        pub(crate) inner: web_tree_sitter_sg::ParserError,
203    }
204
205    unsafe impl Send for ParserError {
206    }
207
208    unsafe impl Sync for ParserError {
209    }
210
211    impl std::fmt::Debug for ParserError {
212        fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
213            std::fmt::Debug::fmt(&self.inner, fmt)
214        }
215    }
216
217    impl std::fmt::Display for ParserError {
218        fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
219            fmt.write_str(&<_ as Into<String>>::into(self.inner.message()))
220        }
221    }
222
223    impl std::error::Error for ParserError {
224    }
225
226    impl From<web_tree_sitter_sg::ParserError> for ParserError {
227        #[inline]
228        fn from(inner: web_tree_sitter_sg::ParserError) -> Self {
229            Self { inner }
230        }
231    }
232
233    #[derive(Eq, PartialEq)]
234    pub struct QueryError {
235        pub(crate) inner: web_tree_sitter_sg::QueryError,
236    }
237
238    unsafe impl Send for QueryError {
239    }
240
241    unsafe impl Sync for QueryError {
242    }
243
244    impl std::fmt::Debug for QueryError {
245        fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
246            std::fmt::Debug::fmt(&self.inner, fmt)
247        }
248    }
249
250    impl std::fmt::Display for QueryError {
251        fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
252            fmt.write_str(&<_ as Into<String>>::into(self.inner.message()))
253        }
254    }
255
256    impl std::error::Error for QueryError {
257    }
258
259    impl From<web_tree_sitter_sg::QueryError> for QueryError {
260        #[inline]
261        fn from(inner: web_tree_sitter_sg::QueryError) -> Self {
262            Self { inner }
263        }
264    }
265}
266
267#[cfg(target_arch = "wasm32")]
268pub use wasm::*;