From 0585e43fa82a359e768815394b493801773feb0c Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Mon, 17 Aug 2020 14:52:11 +0200 Subject: add Log::errors convenience method --- src/lib.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index b3c587d..cd483da 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -897,4 +897,20 @@ impl Log { } }) } + + /// Returns all error strings that were captured. + /// + /// If no errors were encountered, an empty vec is returned. + /// + /// Note that those are errors reported verbatim by arcdps, nothing that evtclib + /// produces/interprets. + pub fn errors(&self) -> Vec<&str> { + self.events().iter().filter_map(|e| { + if let EventKind::Error { ref text } = e.kind() { + Some(text as &str) + } else { + None + } + }).collect() + } } -- cgit v1.2.3