ipfs_api_prelude/
error.rs

1// Copyright 2021 rust-ipfs-api Developers
2//
3// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
4// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
5// http://opensource.org/licenses/MIT>, at your option. This file may not be
6// copied, modified, or distributed except according to those terms.
7//
8
9use std::{io, string::FromUtf8Error};
10use thiserror::Error;
11
12#[derive(Debug, Error)]
13pub enum Error {
14    #[error("io error `{0}`")]
15    Io(#[from] io::Error),
16
17    #[error("utf8 decoding error `{0}`")]
18    ParseUtf8(#[from] FromUtf8Error),
19
20    #[error("json decoding error `{0}`")]
21    Parse(#[from] serde_json::Error),
22
23    #[error("uri error `{0}`")]
24    Url(#[from] http::uri::InvalidUri),
25
26    #[error("url encoding error `{0}`")]
27    EncodeUrl(#[from] serde_urlencoded::ser::Error),
28
29    #[error("api returned an error while streaming `{0}`")]
30    StreamError(String),
31
32    #[error("api got unrecognized trailer header `{0}`")]
33    UnrecognizedTrailerHeader(String),
34
35    #[error("api returned an unknown error `{0}`")]
36    UnrecognizedApiError(String),
37}