Skip to content

Commit

Permalink
impl std::io::Error for ErrorType using thiserror apify#84
Browse files Browse the repository at this point in the history
  • Loading branch information
FjodorGit committed Mar 6, 2025
1 parent bc8f630 commit 5205e8c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
15 changes: 8 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions impit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ num-bigint = "0.4.6"
reqwest = { version = "0.12.9", features = ["json", "gzip", "brotli", "zstd", "deflate", "rustls-tls", "http3", "cookies", "stream"] }
rustls = { version="0.23.16", features=["impit"] }
scraper = "0.22.0"
thiserror = "2.0.12"
tokio = { version="1.40.0", features = ["full"] }
url = "2.5.2"
webpki-roots = "0.26.6"
Expand Down
8 changes: 7 additions & 1 deletion impit/src/impit.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use log::debug;
use reqwest::{Method, Response, Version};
use std::{str::FromStr, time::Duration};
use thiserror::Error;
use url::Url;

use crate::{
Expand All @@ -11,17 +12,22 @@ use crate::{
///
/// The `ErrorType` enum is used to represent the different types of errors that can occur when making requests.
/// The `RequestError` variant is used to wrap the `reqwest::Error` type.
#[derive(Debug)]
#[derive(Error, Debug)]
pub enum ErrorType {
/// The URL couldn't be parsed.
#[error("The URL couldn't be parsed.")]
UrlParsingError,
/// The URL is missing the hostname.
#[error("The URL is missing the hostname.")]
UrlMissingHostnameError,
/// The URL uses an unsupported protocol.
#[error("The URL uses an unsupported protocol.")]
UrlProtocolError,
/// The request was made with `http3_prior_knowledge`, but HTTP/3 usage wasn't enabled.
#[error("The request was made with `http3_prior_knowledge`, but HTTP/3 usage wasn't enabled.")]
Http3Disabled,
/// `reqwest::Error` variant. See the nested error for more details.
#[error("`reqwest::Error` variant. See the nested error for more details: {0}")]
RequestError(reqwest::Error),
}

Expand Down

0 comments on commit 5205e8c

Please sign in to comment.