switchyard/api/errors/
map.rs1use std::io::ErrorKind;
2
3use super::ErrorId;
4
5#[must_use]
7pub fn map_swap_error(e: &std::io::Error) -> ErrorId {
8 let emsg = e.to_string();
9 if emsg.contains("sidecar write failed") {
10 return ErrorId::E_POLICY;
11 }
12 match e.raw_os_error() {
13 Some(code) if code == libc::EXDEV => ErrorId::E_EXDEV,
14 _ => ErrorId::E_ATOMIC_SWAP,
15 }
16}
17
18#[must_use]
23pub const fn map_restore_error_kind(kind: ErrorKind) -> ErrorId {
24 match kind {
25 ErrorKind::NotFound => ErrorId::E_BACKUP_MISSING,
26 _ => ErrorId::E_RESTORE_FAILED,
27 }
28}