Skip to main content

wave_runtime/
error.rs

1// Copyright 2026 Ojima Abraham
2// SPDX-License-Identifier: Apache-2.0
3
4//! Runtime error types for the WAVE runtime.
5//!
6//! Unifies errors from all stages of the pipeline: compilation, backend
7//! translation, device detection, memory management, and kernel launch.
8
9use thiserror::Error;
10
11/// Errors that can occur during WAVE runtime operations.
12#[derive(Debug, Error)]
13pub enum RuntimeError {
14    /// Kernel source compilation failed.
15    #[error("compilation error: {0}")]
16    Compile(String),
17
18    /// Backend translation failed.
19    #[error("backend error: {0}")]
20    Backend(String),
21
22    /// GPU device detection failed.
23    #[error("device error: {0}")]
24    Device(String),
25
26    /// Memory operation failed.
27    #[error("memory error: {0}")]
28    Memory(String),
29
30    /// Kernel launch failed.
31    #[error("launch error: {0}")]
32    Launch(String),
33
34    /// Emulator execution failed.
35    #[error("emulator error: {0}")]
36    Emulator(String),
37
38    /// I/O error during subprocess or file operations.
39    #[error("I/O error: {0}")]
40    Io(String),
41
42    /// Invalid argument provided.
43    #[error("invalid argument: {0}")]
44    InvalidArgument(String),
45}
46
47impl From<wave_compiler::CompileError> for RuntimeError {
48    fn from(e: wave_compiler::CompileError) -> Self {
49        Self::Compile(e.to_string())
50    }
51}
52
53impl From<wave_emu::EmulatorError> for RuntimeError {
54    fn from(e: wave_emu::EmulatorError) -> Self {
55        Self::Emulator(e.to_string())
56    }
57}
58
59impl From<std::io::Error> for RuntimeError {
60    fn from(e: std::io::Error) -> Self {
61        Self::Io(e.to_string())
62    }
63}