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