ifc_lite_geometry_runtime/
worker_error.rs

1// SPDX-License-Identifier: MPL-2.0
2//! Errors reported by the native worker client.
3
4#[derive(Debug)]
5pub enum WorkerError {
6    Io(std::io::Error),
7    Protocol(&'static str),
8    Kernel {
9        status: i32,
10        message: String,
11    },
12    WrongWorker,
13    /// Caller input refused before any request reached the worker.
14    InvalidArgument(&'static str),
15    ResourceLimit(&'static str),
16    /// A retained request needs a same-incarnation numerical witness that has
17    /// not passed; nothing was uploaded.
18    Unqualified(&'static str),
19}
20
21impl std::fmt::Display for WorkerError {
22    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23        match self {
24            Self::Io(error) => write!(f, "geometry worker IO: {error}"),
25            Self::Protocol(message) => write!(f, "geometry worker protocol: {message}"),
26            Self::Kernel { status, message } => {
27                write!(f, "geometry worker status {status}: {message}")
28            }
29            Self::InvalidArgument(message) => {
30                write!(f, "invalid geometry worker argument: {message}")
31            }
32            Self::WrongWorker => write!(f, "BRep handle belongs to another worker"),
33            Self::ResourceLimit(message) => write!(f, "geometry worker resource limit: {message}"),
34            Self::Unqualified(message) => write!(f, "unqualified retained request: {message}"),
35        }
36    }
37}
38impl std::error::Error for WorkerError {}
39impl From<std::io::Error> for WorkerError {
40    fn from(error: std::io::Error) -> Self {
41        Self::Io(error)
42    }
43}