Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to return custom errors #21

Open
CowBoy4mH3LL opened this issue Aug 26, 2024 · 1 comment
Open

Ability to return custom errors #21

CowBoy4mH3LL opened this issue Aug 26, 2024 · 1 comment
Assignees

Comments

@CowBoy4mH3LL
Copy link

Say I have a custom error SError{message:String} and I implement From<std:io:Error> on it.
Now, from a function, say, fn(&self) -> Result<(),SError> in an rtc::remote labelled trait, I get an std:io:error as a result of calling await on some other async function.
Even if I have implemented the From cast from Error to SError, it does not seem to be able to cast between the output Result forms.
Any idea why?

@surban
Copy link
Member

surban commented Sep 3, 2024

Your custom error type must be serializable and it must implement From<CallError>.

For example:

// Custom error type that can convert from CallError.
#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub enum IncreaseError {
    Overflow,
    Call(CallError),
}

impl From<CallError> for IncreaseError {
    fn from(err: CallError) -> Self {
        Self::Call(err)
    }
}

@surban surban self-assigned this Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@surban @CowBoy4mH3LL and others