use derive_more::*;
use std::fmt::{Debug, Display};
#[derive(Copy, Clone, Eq, PartialEq, Debug, Display, Error)]
#[display(fmt = "REAPER function failed: {}", message)]
pub struct ReaperFunctionError {
message: &'static str,
}
impl ReaperFunctionError {
pub(crate) fn new(message: &'static str) -> ReaperFunctionError {
ReaperFunctionError { message }
}
}
pub(crate) type ReaperFunctionResult<T> = Result<T, ReaperFunctionError>;
#[derive(Debug, Clone, Eq, PartialEq, Display)]
#[display(fmt = "conversion from raw value [{}] failed: {}", raw_value, message)]
pub struct TryFromRawError<R> {
message: &'static str,
raw_value: R,
}
impl<R: Copy> TryFromRawError<R> {
pub(crate) fn new(message: &'static str, raw_value: R) -> TryFromRawError<R> {
TryFromRawError { message, raw_value }
}
}
impl<R: Copy + Display + Debug> std::error::Error for TryFromRawError<R> {}