Skip to content

Commit

Permalink
feat: Add Unsupported variant to CacheError and ObjectFileStatus
Browse files Browse the repository at this point in the history
This is the part of #1541
that just introduces the variants but doesn't yet produce
them anywhere.
  • Loading branch information
loewenheim committed Nov 15, 2024
1 parent a70c686 commit fd4c74b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/symbolicator-js/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ impl From<CacheError> for JsScrapingResult {
),
CacheError::DownloadError(details) => (JsScrapingFailureReason::DownloadError, details),
CacheError::Malformed(details) => (JsScrapingFailureReason::Other, details),
CacheError::Unsupported(details) => (JsScrapingFailureReason::Other, details),
CacheError::InternalError => (JsScrapingFailureReason::Other, String::new()),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub fn object_file_status_from_cache_entry<T>(cache_entry: &CacheEntry<T>) -> Ob
}
Err(CacheError::Timeout(_)) => ObjectFileStatus::Timeout,
Err(CacheError::Malformed(_)) => ObjectFileStatus::Malformed,
Err(CacheError::Unsupported(_)) => ObjectFileStatus::Unsupported,
Err(CacheError::InternalError) => ObjectFileStatus::Other,
}
}
Expand Down
16 changes: 16 additions & 0 deletions crates/symbolicator-service/src/caching/cache_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ pub enum CacheError {
/// during symcache conversion
#[error("malformed: {0}")]
Malformed(String),
/// The object is of a type that cannot be used for the symbolication task it was
/// requested for.
///
/// This is currently only used when we try to symbolicate a .NET event with a Windows
/// PDB file. A tracking issue in `symbolic` for supporting this case is
/// [here](https://github.com/getsentry/symbolic/issues/871).
#[error("unsupported: {0}")]
Unsupported(String),
/// An unexpected error in symbolicator itself.
///
/// This variant is not intended to be persisted to or read from caches.
Expand All @@ -64,6 +72,7 @@ impl CacheError {
pub(super) const PERMISSION_DENIED_MARKER: &'static [u8] = b"permissiondenied";
pub(super) const TIMEOUT_MARKER: &'static [u8] = b"timeout";
pub(super) const DOWNLOAD_ERROR_MARKER: &'static [u8] = b"downloaderror";
pub(super) const UNSUPPORTED_MARKER: &'static [u8] = b"unsupported";

/// Writes error markers and details to a file.
///
Expand Down Expand Up @@ -99,6 +108,10 @@ impl CacheError {
file.write_all(Self::DOWNLOAD_ERROR_MARKER).await?;
file.write_all(details.as_bytes()).await?;
}
CacheError::Unsupported(details) => {
file.write_all(Self::UNSUPPORTED_MARKER).await?;
file.write_all(details.as_bytes()).await?;
}
CacheError::InternalError => {
unreachable!("this was already handled above");
}
Expand Down Expand Up @@ -134,6 +147,9 @@ impl CacheError {
} else if let Some(raw_message) = bytes.strip_prefix(Self::MALFORMED_MARKER) {
let err_msg = utf8_message(raw_message);
Some(Self::Malformed(err_msg.into_owned()))
} else if let Some(raw_message) = bytes.strip_prefix(Self::UNSUPPORTED_MARKER) {
let err_msg = utf8_message(raw_message);
Some(Self::Unsupported(err_msg.into_owned()))
} else if bytes.is_empty() {
Some(Self::NotFound)
} else {
Expand Down
7 changes: 7 additions & 0 deletions crates/symbolicator-service/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ pub enum ObjectFileStatus {
FetchingFailed,
/// Downloading or processing the file took too long.
Timeout,
/// The file could not be used for the purpose for which it was requested.
///
/// This is currently only used when we try to symbolicate a .NET event with a Windows
/// PDB file. A tracking issue in `symbolic` for supporting this case is
/// [here](https://github.com/getsentry/symbolic/issues/871).
Unsupported,
/// An internal error while handling this image.
Other,
}
Expand All @@ -161,6 +167,7 @@ impl ObjectFileStatus {
ObjectFileStatus::Malformed => "malformed",
ObjectFileStatus::FetchingFailed => "fetching_failed",
ObjectFileStatus::Timeout => "timeout",
ObjectFileStatus::Unsupported => "unsupported",
ObjectFileStatus::Other => "other",
}
}
Expand Down

0 comments on commit fd4c74b

Please sign in to comment.