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
use std::fmt::{self, Display, Formatter};
#[derive(Debug)]
pub struct Error(ErrorKind);
impl Error {
pub(crate) fn library(cause: libloading::Error) -> Self {
Error(ErrorKind::Library(cause))
}
pub(crate) fn symbol(cause: libloading::Error) -> Self {
Error(ErrorKind::Symbol(cause))
}
pub(crate) fn no_compatible_api() -> Self {
Error(ErrorKind::NoCompatibleApi)
}
pub(crate) fn launch_replay_ui() -> Self {
Error(ErrorKind::LaunchReplayUi)
}
}
impl Display for Error {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
match self.0 {
ErrorKind::Library(_) => write!(f, "Unable to load RenderDoc shared library"),
ErrorKind::Symbol(_) => write!(f, "Unable to find `RENDERDOC_GetAPI` symbol"),
ErrorKind::NoCompatibleApi => write!(f, "Library could not provide compatible API"),
ErrorKind::LaunchReplayUi => write!(f, "Failed to launch replay UI"),
}
}
}
impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self.0 {
ErrorKind::Library(ref e) | ErrorKind::Symbol(ref e) => Some(e),
_ => None,
}
}
}
#[derive(Debug)]
enum ErrorKind {
Library(libloading::Error),
Symbol(libloading::Error),
NoCompatibleApi,
LaunchReplayUi,
}