1use derive_more::*;
2use std::fmt::{Debug, Display};
3
4#[derive(Copy, Clone, Eq, PartialEq, Debug, Display, Error)]
10#[display(fmt = "REAPER function failed: {}", message)]
11pub struct ReaperFunctionError {
12 message: &'static str,
13}
14
15impl ReaperFunctionError {
16 pub(crate) fn new(message: &'static str) -> ReaperFunctionError {
17 ReaperFunctionError { message }
18 }
19}
20
21pub(crate) type ReaperFunctionResult<T> = Result<T, ReaperFunctionError>;
22
23#[derive(Debug, Clone, Eq, PartialEq, Display)]
27#[display(fmt = "conversion from raw value [{}] failed: {}", raw_value, message)]
28pub struct TryFromRawError<R> {
29 message: &'static str,
30 raw_value: R,
31}
32
33impl<R: Copy> TryFromRawError<R> {
34 pub(crate) fn new(message: &'static str, raw_value: R) -> TryFromRawError<R> {
35 TryFromRawError { message, raw_value }
36 }
37}
38
39impl<R: Copy + Display + Debug> std::error::Error for TryFromRawError<R> {}