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
/*
 * File: error.rs
 * Project: src
 * Created Date: 27/04/2022
 * Author: Shun Suzuki
 * -----
 * Last Modified: 02/06/2023
 * Modified By: Shun Suzuki (suzuki@hapis.k.u-tokyo.ac.jp)
 * -----
 * Copyright (c) 2022-2023 Shun Suzuki. All rights reserved.
 *
 */

use thiserror::Error;

use super::osal_timer::error::TimerError;
use autd3_driver::MAX_CYCLE;

#[derive(Error, Debug)]
pub enum AUTDInternalError {
    #[error("Link is closed")]
    LinkClosed,
    #[error("{0}")]
    LinkError(String),
    #[error("{0}")]
    GainError(String),
    #[error("{0}")]
    ModulationError(String),
    #[error("Maximum cycle is {} , but {0} is specified", MAX_CYCLE)]
    CycleOutOfRange(u16),
    #[error("The maximum number of transducers per device is 256")]
    TooManyTransducers,
    #[error("{0}")]
    TimerError(TimerError),
}

impl From<TimerError> for AUTDInternalError {
    fn from(e: TimerError) -> Self {
        AUTDInternalError::TimerError(e)
    }
}