Skip to content

Commit

Permalink
fix: add JsError to error structs that dont have it (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
crowlKats authored Dec 18, 2024
1 parent 79bdbc1 commit 0270738
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion rs_lib/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,12 @@ pub fn url_to_filename(url: &Url) -> std::io::Result<PathBuf> {
Ok(cache_filename)
}

#[derive(Debug, Error)]
#[derive(Debug, Error, JsError)]
pub enum CacheReadFileError {
#[class(inherit)]
#[error(transparent)]
Io(#[from] std::io::Error),
#[class(inherit)]
#[error(transparent)]
ChecksumIntegrity(Box<ChecksumIntegrityError>),
}
Expand Down
10 changes: 7 additions & 3 deletions rs_lib/src/file_fetcher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ pub struct CacheReadError {
pub source: std::io::Error,
}

#[derive(Debug, Error)]
#[derive(Debug, Error, JsError)]
#[class(generic)]
#[error("Failed reading location header for '{}'{}", .request_url, .maybe_location.as_ref().map(|location| format!(" to '{}'", location)).unwrap_or_default())]
pub struct RedirectHeaderParseError {
pub request_url: Url,
Expand Down Expand Up @@ -344,15 +345,18 @@ impl From<FetchLocalError> for FetchNoFollowError {
}
}

#[derive(Debug, Boxed)]
#[derive(Debug, Boxed, JsError)]
struct FetchCachedNoFollowError(pub Box<FetchCachedNoFollowErrorKind>);

#[derive(Debug, Error)]
#[derive(Debug, Error, JsError)]
enum FetchCachedNoFollowErrorKind {
#[class(inherit)]
#[error(transparent)]
ChecksumIntegrity(ChecksumIntegrityError),
#[class(inherit)]
#[error(transparent)]
CacheRead(#[from] CacheReadError),
#[class(inherit)]
#[error(transparent)]
RedirectResolution(#[from] RedirectResolutionError),
}
Expand Down

0 comments on commit 0270738

Please sign in to comment.