oak-core 0.0.11

Core parser combinator library providing fundamental parsing primitives.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
use crate::source::SourceId;

/// Result type for parsing operations.
pub type ParseResult<T> = Result<T, OakError>;

/// Diagnostic information for parsing operations.
///
/// Contains both the primary result and any non-fatal errors or warnings.
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(bound(serialize = "T: serde::Serialize", deserialize = "T: serde::Deserialize<'de>")))]
pub struct OakDiagnostics<T> {
    /// The primary result of the parsing operation.
    /// May contain either a successful value or a fatal error.
    pub result: Result<T, OakError>,
    /// A collection of non-fatal errors or warnings encountered during the operation.
    pub diagnostics: Vec<OakError>,
}

impl<T: Clone> Clone for OakDiagnostics<T> {
    fn clone(&self) -> Self {
        Self { result: self.result.clone(), diagnostics: self.diagnostics.clone() }
    }
}

impl<T> OakDiagnostics<T> {
    /// Creates a new OakDiagnostics with the given result and no diagnostics.
    pub fn new(result: Result<T, OakError>) -> Self {
        Self { result, diagnostics: Vec::new() }
    }

    /// Creates a new OakDiagnostics with a successful result.
    pub fn success(value: T) -> Self {
        Self { result: Ok(value), diagnostics: Vec::new() }
    }

    /// Creates a new OakDiagnostics with a fatal error.
    pub fn error(error: OakError) -> Self {
        Self { result: Err(error), diagnostics: Vec::new() }
    }

    /// Returns true if there are any fatal errors or diagnostics.
    pub fn has_errors(&self) -> bool {
        self.result.is_err() || !self.diagnostics.is_empty()
    }
}

impl<'a, L: crate::Language> OakDiagnostics<&'a crate::tree::GreenNode<'a, L>> {
    /// Returns the successful green node result, panicking on error.
    pub fn green(&self) -> &'a crate::tree::GreenNode<'a, L> {
        self.result.as_ref().expect("Failed to get green node from parse output")
    }
}

/// The main error type for the Oak Core parsing framework.
///
/// `OakError` represents all possible language that can occur during
/// lexical analysis and parsing operations. It provides detailed
/// error information including error kind and precise source location.
#[derive(Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct OakError {
    /// The specific kind of error.
    kind: Box<OakErrorKind>,
}

impl OakError {
    /// Creates a new OakError with the given kind.
    pub fn new(kind: OakErrorKind) -> Self {
        Self { kind: Box::new(kind) }
    }

    /// Creates a new custom error with the given message.
    pub fn custom_error(message: impl Into<String>) -> Self {
        Self::new(OakErrorKind::CustomError { message: message.into() })
    }
}

impl From<OakErrorKind> for OakError {
    fn from(kind: OakErrorKind) -> Self {
        Self { kind: Box::new(kind) }
    }
}

impl std::fmt::Debug for OakError {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        std::fmt::Display::fmt(self, f)
    }
}

impl std::fmt::Display for OakError {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "{:?}", self.kind)
    }
}

impl std::error::Error for OakError {}

#[cfg(feature = "serde")]
impl serde::ser::Error for OakError {
    fn custom<T: std::fmt::Display>(msg: T) -> Self {
        OakError::serde_error(msg.to_string())
    }
}

#[cfg(feature = "serde")]
impl serde::de::Error for OakError {
    fn custom<T: std::fmt::Display>(msg: T) -> Self {
        OakError::deserialize_error(msg.to_string())
    }
}

#[cfg(feature = "serde")]
mod serde_io_error {
    pub fn serialize<S>(error: &std::io::Error, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serde::Serialize::serialize(&error.to_string(), serializer)
    }

    pub fn deserialize<'de, D>(deserializer: D) -> Result<std::io::Error, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = <String as serde::Deserialize>::deserialize(deserializer)?;
        Ok(std::io::Error::new(std::io::ErrorKind::Other, s))
    }
}

/// Enumeration of all possible error kinds in the Oak Core framework.
///
/// This enum categorizes different types of language that can occur
/// during parsing operations, each with specific associated data
/// relevant to that error type.
#[derive(Debug)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum OakErrorKind {
    /// I/O error that occurred while reading source files.
    IoError {
        /// The underlying I/O error.
        #[cfg_attr(feature = "serde", serde(with = "crate::errors::serde_io_error"))]
        error: std::io::Error,
        /// Optional source ID of the file that caused the error.
        source_id: Option<SourceId>,
    },
    /// Syntax error encountered during parsing.
    SyntaxError {
        /// The error message.
        message: String,
        /// The byte offset where the error occurred.
        offset: usize,
        /// Optional source ID of the file that caused the error.
        source_id: Option<SourceId>,
    },
    /// Unexpected character encountered during lexical analysis.
    UnexpectedCharacter {
        /// The character that was not expected at this position.
        character: char,
        /// The byte offset where the unexpected character was found.
        offset: usize,
        /// Optional source ID of the file that caused the error.
        source_id: Option<SourceId>,
    },

    /// Unexpected token encountered during parsing.
    UnexpectedToken {
        /// The token that was not expected.
        token: String,
        /// The byte offset where the unexpected token was found.
        offset: usize,
        /// Optional source ID of the file that caused the error.
        source_id: Option<SourceId>,
    },

    /// Unexpected end of file encountered during parsing.
    UnexpectedEof {
        /// The byte offset where the EOF was encountered.
        offset: usize,
        /// Optional source ID of the file that caused the error.
        source_id: Option<SourceId>,
    },

    /// Custom error for user-defined error conditions.
    CustomError {
        /// The error message.
        message: String,
    },

    /// Invalid theme error for highlighting.
    InvalidTheme {
        /// The error message.
        message: String,
    },

    /// Unsupported format error for exporting.
    UnsupportedFormat {
        /// The unsupported format.
        format: String,
    },

    /// Color parsing error for themes.
    ColorParseError {
        /// The invalid color string.
        color: String,
    },

    /// Formatting error.
    FormatError {
        /// The error message.
        message: String,
    },

    /// Semantic error.
    SemanticError {
        /// The error message.
        message: String,
    },

    /// Protocol error (e.g., MCP, LSP).
    ProtocolError {
        /// The error message.
        message: String,
    },

    /// Expected a specific token.
    ExpectedToken {
        /// The token that was expected.
        expected: String,
        /// The byte offset where the error occurred.
        offset: usize,
        /// Optional source ID of the file that caused the error.
        source_id: Option<SourceId>,
    },

    /// Expected a name (identifier).
    ExpectedName {
        /// The kind of name that was expected (e.g., "function name").
        name_kind: String,
        /// The byte offset where the error occurred.
        offset: usize,
        /// Optional source ID of the file that caused the error.
        source_id: Option<SourceId>,
    },

    /// Trailing comma is not allowed.
    TrailingCommaNotAllowed {
        /// The byte offset where the error occurred.
        offset: usize,
        /// Optional source ID of the file that caused the error.
        source_id: Option<SourceId>,
    },

    /// Test failure error.
    TestFailure {
        /// The file that failed the test.
        path: std::path::PathBuf,
        /// The expected output.
        expected: String,
        /// The actual output.
        actual: String,
    },

    /// Test regenerated.
    TestRegenerated {
        /// The file that was regenerated.
        path: std::path::PathBuf,
    },

    /// Serde error.
    SerdeError {
        /// The error message.
        message: String,
    },

    /// Serde deserialization error.
    DeserializeError {
        /// The error message.
        message: String,
    },

    /// XML error.
    XmlError {
        /// The error message.
        message: String,
    },

    /// Zip error.
    ZipError {
        /// The error message.
        message: String,
    },

    /// Parse error.
    ParseError {
        /// The error message.
        message: String,
    },

    /// Internal error.
    InternalError {
        /// The error message.
        message: String,
    },
}

impl OakErrorKind {
    /// Gets the i18n key for this error kind.
    pub fn key(&self) -> &'static str {
        match self {
            OakErrorKind::IoError { .. } => "error.io",
            OakErrorKind::SyntaxError { .. } => "error.syntax",
            OakErrorKind::UnexpectedCharacter { .. } => "error.unexpected_character",
            OakErrorKind::UnexpectedToken { .. } => "error.unexpected_token",
            OakErrorKind::UnexpectedEof { .. } => "error.unexpected_eof",
            OakErrorKind::CustomError { .. } => "error.custom",
            OakErrorKind::InvalidTheme { .. } => "error.invalid_theme",
            OakErrorKind::UnsupportedFormat { .. } => "error.unsupported_format",
            OakErrorKind::ColorParseError { .. } => "error.color_parse",
            OakErrorKind::FormatError { .. } => "error.format",
            OakErrorKind::SemanticError { .. } => "error.semantic",
            OakErrorKind::ProtocolError { .. } => "error.protocol",
            OakErrorKind::ExpectedToken { .. } => "error.expected_token",
            OakErrorKind::ExpectedName { .. } => "error.expected_name",
            OakErrorKind::TrailingCommaNotAllowed { .. } => "error.trailing_comma_not_allowed",
            OakErrorKind::TestFailure { .. } => "error.test_failure",
            OakErrorKind::TestRegenerated { .. } => "error.test_regenerated",
            OakErrorKind::SerdeError { .. } => "error.serde",
            OakErrorKind::DeserializeError { .. } => "error.deserialize",
            OakErrorKind::XmlError { .. } => "error.xml",
            OakErrorKind::ZipError { .. } => "error.zip",
            OakErrorKind::ParseError { .. } => "error.parse",
            OakErrorKind::InternalError { .. } => "error.internal",
        }
    }
}

impl std::fmt::Display for OakErrorKind {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            OakErrorKind::IoError { error, source_id } => {
                if let Some(id) = source_id {
                    write!(f, "I/O error in {}: {}", id, error)
                }
                else {
                    write!(f, "I/O error: {}", error)
                }
            }
            OakErrorKind::SyntaxError { message, offset, source_id } => {
                if let Some(id) = source_id {
                    write!(f, "Syntax error in {} at offset {}: {}", id, offset, message)
                }
                else {
                    write!(f, "Syntax error at offset {}: {}", offset, message)
                }
            }
            OakErrorKind::UnexpectedCharacter { character, offset, source_id } => {
                if let Some(id) = source_id {
                    write!(f, "Unexpected character '{}' in {} at offset {}", character, id, offset)
                }
                else {
                    write!(f, "Unexpected character '{}' at offset {}", character, offset)
                }
            }
            OakErrorKind::UnexpectedToken { token, offset, source_id } => {
                if let Some(id) = source_id {
                    write!(f, "Unexpected token '{}' in {} at offset {}", token, id, offset)
                }
                else {
                    write!(f, "Unexpected token '{}' at offset {}", token, offset)
                }
            }
            OakErrorKind::UnexpectedEof { offset, source_id } => {
                if let Some(id) = source_id {
                    write!(f, "Unexpected end of file in {} at offset {}", id, offset)
                }
                else {
                    write!(f, "Unexpected end of file at offset {}", offset)
                }
            }
            OakErrorKind::ExpectedToken { expected, offset, source_id } => {
                if let Some(id) = source_id {
                    write!(f, "Expected token '{}' in {} at offset {}", expected, id, offset)
                }
                else {
                    write!(f, "Expected token '{}' at offset {}", expected, offset)
                }
            }
            OakErrorKind::ExpectedName { name_kind, offset, source_id } => {
                if let Some(id) = source_id {
                    write!(f, "Expected {} in {} at offset {}", name_kind, id, offset)
                }
                else {
                    write!(f, "Expected {} at offset {}", name_kind, offset)
                }
            }
            OakErrorKind::TrailingCommaNotAllowed { offset, source_id } => {
                if let Some(id) = source_id {
                    write!(f, "Trailing comma not allowed in {} at offset {}", id, offset)
                }
                else {
                    write!(f, "Trailing comma not allowed at offset {}", offset)
                }
            }
            OakErrorKind::CustomError { message } => {
                write!(f, "Custom error: {}", message)
            }
            OakErrorKind::InvalidTheme { message } => {
                write!(f, "Invalid theme: {}", message)
            }
            OakErrorKind::UnsupportedFormat { format } => {
                write!(f, "Unsupported format: {}", format)
            }
            OakErrorKind::ColorParseError { color } => {
                write!(f, "Invalid color: {}", color)
            }
            OakErrorKind::FormatError { message } => {
                write!(f, "Format error: {}", message)
            }
            OakErrorKind::SemanticError { message } => {
                write!(f, "Semantic error: {}", message)
            }
            OakErrorKind::ProtocolError { message } => {
                write!(f, "Protocol error: {}", message)
            }
            OakErrorKind::TestFailure { path, expected, actual } => {
                write!(f, "Test failed for {}: expected '{}', got '{}'", path.display(), expected, actual)
            }
            OakErrorKind::TestRegenerated { path } => {
                write!(f, "Test regenerated for {}", path.display())
            }
            OakErrorKind::SerdeError { message } => {
                write!(f, "Serialization error: {}", message)
            }
            OakErrorKind::DeserializeError { message } => {
                write!(f, "Deserialization error: {}", message)
            }
            OakErrorKind::XmlError { message } => {
                write!(f, "XML error: {}", message)
            }
            OakErrorKind::ZipError { message } => {
                write!(f, "ZIP error: {}", message)
            }
            OakErrorKind::ParseError { message } => {
                write!(f, "Parse error: {}", message)
            }
            OakErrorKind::InternalError { message } => {
                write!(f, "Internal error: {}", message)
            }
        }
    }
}

impl OakError {
    /// Gets the kind of this error.
    pub fn kind(&self) -> &OakErrorKind {
        &self.kind
    }

    /// Creates a test failure error.
    pub fn test_failure(path: std::path::PathBuf, expected: String, actual: String) -> Self {
        OakErrorKind::TestFailure { path, expected, actual }.into()
    }

    /// Creates a test regenerated error.
    pub fn test_regenerated(path: std::path::PathBuf) -> Self {
        OakErrorKind::TestRegenerated { path }.into()
    }

    /// Creates an I/O error with optional Source ID.
    pub fn io_error(error: std::io::Error, source_id: SourceId) -> Self {
        OakErrorKind::IoError { error, source_id: Some(source_id) }.into()
    }

    /// Creates a syntax error with a message and location.
    pub fn syntax_error(message: impl Into<String>, offset: usize, source_id: Option<SourceId>) -> Self {
        OakErrorKind::SyntaxError { message: message.into(), offset, source_id }.into()
    }

    /// Creates an unexpected character error.
    pub fn unexpected_character(character: char, offset: usize, source_id: Option<SourceId>) -> Self {
        OakErrorKind::UnexpectedCharacter { character, offset, source_id }.into()
    }

    /// Creates an unexpected token error.
    pub fn unexpected_token(token: impl Into<String>, offset: usize, source_id: Option<SourceId>) -> Self {
        OakErrorKind::UnexpectedToken { token: token.into(), offset, source_id }.into()
    }

    /// Creates an unexpected end of file error.
    pub fn unexpected_eof(offset: usize, source_id: Option<SourceId>) -> Self {
        OakErrorKind::UnexpectedEof { offset, source_id }.into()
    }

    /// Creates an expected token error.
    pub fn expected_token(expected: impl Into<String>, offset: usize, source_id: Option<SourceId>) -> Self {
        OakErrorKind::ExpectedToken { expected: expected.into(), offset, source_id }.into()
    }

    /// Creates an expected name error.
    pub fn expected_name(name_kind: impl Into<String>, offset: usize, source_id: Option<SourceId>) -> Self {
        OakErrorKind::ExpectedName { name_kind: name_kind.into(), offset, source_id }.into()
    }

    /// Creates a trailing comma not allowed error.
    pub fn trailing_comma_not_allowed(offset: usize, source_id: Option<SourceId>) -> Self {
        OakErrorKind::TrailingCommaNotAllowed { offset, source_id }.into()
    }

    /// Creates an invalid theme error.
    pub fn invalid_theme(message: impl Into<String>) -> Self {
        OakErrorKind::InvalidTheme { message: message.into() }.into()
    }

    /// Creates an unsupported format error.
    pub fn unsupported_format(format: impl Into<String>) -> Self {
        OakErrorKind::UnsupportedFormat { format: format.into() }.into()
    }

    /// Creates a color parsing error.
    pub fn color_parse_error(color: impl Into<String>) -> Self {
        OakErrorKind::ColorParseError { color: color.into() }.into()
    }

    /// Creates a formatting error.
    pub fn format_error(message: impl Into<String>) -> Self {
        OakErrorKind::FormatError { message: message.into() }.into()
    }

    /// Creates a semantic error.
    pub fn semantic_error(message: impl Into<String>) -> Self {
        OakErrorKind::SemanticError { message: message.into() }.into()
    }

    /// Creates a protocol error.
    pub fn protocol_error(message: impl Into<String>) -> Self {
        OakErrorKind::ProtocolError { message: message.into() }.into()
    }

    /// Creates a serde error.
    pub fn serde_error(message: impl Into<String>) -> Self {
        OakErrorKind::SerdeError { message: message.into() }.into()
    }

    /// Creates a serde deserialization error.
    pub fn deserialize_error(message: impl Into<String>) -> Self {
        OakErrorKind::DeserializeError { message: message.into() }.into()
    }

    /// Creates an XML error.
    pub fn xml_error(message: impl Into<String>) -> Self {
        OakErrorKind::XmlError { message: message.into() }.into()
    }

    /// Creates a zip error.
    pub fn zip_error(message: impl Into<String>) -> Self {
        OakErrorKind::ZipError { message: message.into() }.into()
    }

    /// Creates a parse error.
    pub fn parse_error(message: impl Into<String>) -> Self {
        OakErrorKind::ParseError { message: message.into() }.into()
    }

    /// Creates an internal error.
    pub fn internal_error(message: impl Into<String>) -> Self {
        OakErrorKind::InternalError { message: message.into() }.into()
    }

    /// Attach a source ID to the error context.
    pub fn with_source_id(mut self, source_id: SourceId) -> Self {
        match self.kind.as_mut() {
            OakErrorKind::IoError { source_id: u, .. } => *u = Some(source_id),
            OakErrorKind::SyntaxError { source_id: u, .. } => *u = Some(source_id),
            OakErrorKind::UnexpectedCharacter { source_id: u, .. } => *u = Some(source_id),
            OakErrorKind::UnexpectedToken { source_id: u, .. } => *u = Some(source_id),
            OakErrorKind::ExpectedToken { source_id: u, .. } => *u = Some(source_id),
            OakErrorKind::ExpectedName { source_id: u, .. } => *u = Some(source_id),
            OakErrorKind::TrailingCommaNotAllowed { source_id: u, .. } => *u = Some(source_id),
            _ => {}
        }
        self
    }
}

impl Clone for OakErrorKind {
    fn clone(&self) -> Self {
        match self {
            OakErrorKind::IoError { error, source_id } => {
                // Since std::io::Error doesn't support Clone, we create a new error
                let new_error = std::io::Error::new(error.kind(), error.to_string());
                OakErrorKind::IoError { error: new_error, source_id: *source_id }
            }
            OakErrorKind::SyntaxError { message, offset, source_id } => OakErrorKind::SyntaxError { message: message.clone(), offset: *offset, source_id: *source_id },
            OakErrorKind::UnexpectedCharacter { character, offset, source_id } => OakErrorKind::UnexpectedCharacter { character: *character, offset: *offset, source_id: *source_id },
            OakErrorKind::UnexpectedToken { token, offset, source_id } => OakErrorKind::UnexpectedToken { token: token.clone(), offset: *offset, source_id: *source_id },
            OakErrorKind::UnexpectedEof { offset, source_id } => OakErrorKind::UnexpectedEof { offset: *offset, source_id: *source_id },
            OakErrorKind::ExpectedToken { expected, offset, source_id } => OakErrorKind::ExpectedToken { expected: expected.clone(), offset: *offset, source_id: *source_id },
            OakErrorKind::ExpectedName { name_kind, offset, source_id } => OakErrorKind::ExpectedName { name_kind: name_kind.clone(), offset: *offset, source_id: *source_id },
            OakErrorKind::TrailingCommaNotAllowed { offset, source_id } => OakErrorKind::TrailingCommaNotAllowed { offset: *offset, source_id: *source_id },
            OakErrorKind::CustomError { message } => OakErrorKind::CustomError { message: message.clone() },
            OakErrorKind::InvalidTheme { message } => OakErrorKind::InvalidTheme { message: message.clone() },
            OakErrorKind::UnsupportedFormat { format } => OakErrorKind::UnsupportedFormat { format: format.clone() },
            OakErrorKind::ColorParseError { color } => OakErrorKind::ColorParseError { color: color.clone() },
            OakErrorKind::FormatError { message } => OakErrorKind::FormatError { message: message.clone() },
            OakErrorKind::SemanticError { message } => OakErrorKind::SemanticError { message: message.clone() },
            OakErrorKind::ProtocolError { message } => OakErrorKind::ProtocolError { message: message.clone() },
            OakErrorKind::TestFailure { path, expected, actual } => OakErrorKind::TestFailure { path: path.clone(), expected: expected.clone(), actual: actual.clone() },
            OakErrorKind::TestRegenerated { path } => OakErrorKind::TestRegenerated { path: path.clone() },
            OakErrorKind::SerdeError { message } => OakErrorKind::SerdeError { message: message.clone() },
            OakErrorKind::DeserializeError { message } => OakErrorKind::DeserializeError { message: message.clone() },
            OakErrorKind::XmlError { message } => OakErrorKind::XmlError { message: message.clone() },
            OakErrorKind::ZipError { message } => OakErrorKind::ZipError { message: message.clone() },
            OakErrorKind::ParseError { message } => OakErrorKind::ParseError { message: message.clone() },
            OakErrorKind::InternalError { message } => OakErrorKind::InternalError { message: message.clone() },
        }
    }
}