Skip to content
This repository was archived by the owner on Mar 25, 2024. It is now read-only.

Commit 4200736

Browse files
committed
Add an error variant with shared ownership
1 parent 7ea4775 commit 4200736

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎src/error.rs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use std::io;
66
use std::result;
77
use std::str;
88
use std::string;
9+
use std::sync::Arc;
910
use yaml_rust::emitter;
1011
use yaml_rust::scanner::{self, Marker, ScanError};
1112

@@ -28,6 +29,8 @@ pub enum ErrorImpl {
2829
EndOfStream,
2930
MoreThanOneDocument,
3031
RecursionLimitExceeded,
32+
33+
Shared(Arc<ErrorImpl>),
3134
}
3235

3336
#[derive(Debug)]
@@ -193,6 +196,7 @@ impl ErrorImpl {
193196
"deserializing from YAML containing more than one document is not supported"
194197
}
195198
ErrorImpl::RecursionLimitExceeded => "recursion limit exceeded",
199+
ErrorImpl::Shared(err) => err.description(),
196200
}
197201
}
198202

@@ -202,6 +206,7 @@ impl ErrorImpl {
202206
ErrorImpl::Io(err) => Some(err),
203207
ErrorImpl::Utf8(err) => Some(err),
204208
ErrorImpl::FromUtf8(err) => Some(err),
209+
ErrorImpl::Shared(err) => err.source(),
205210
_ => None,
206211
}
207212
}
@@ -227,6 +232,7 @@ impl ErrorImpl {
227232
"deserializing from YAML containing more than one document is not supported",
228233
),
229234
ErrorImpl::RecursionLimitExceeded => f.write_str("recursion limit exceeded"),
235+
ErrorImpl::Shared(err) => err.display(f),
230236
}
231237
}
232238

@@ -241,6 +247,7 @@ impl ErrorImpl {
241247
ErrorImpl::EndOfStream => f.debug_tuple("EndOfStream").finish(),
242248
ErrorImpl::MoreThanOneDocument => f.debug_tuple("MoreThanOneDocument").finish(),
243249
ErrorImpl::RecursionLimitExceeded => f.debug_tuple("RecursionLimitExceeded").finish(),
250+
ErrorImpl::Shared(err) => err.debug(f),
244251
}
245252
}
246253
}

0 commit comments

Comments
 (0)