Skip to content

Commit

Permalink
feat: log error source on snap name call
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew-hagemann committed Jan 14, 2025
1 parent 897b0bc commit ddde201
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/grpc/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{
ratings::{get_snap_name, Rating},
Context,
};
use std::sync::Arc;
use std::{sync::Arc, error::Error};
use tonic::{Request, Response, Status};
use tracing::error;

Expand Down Expand Up @@ -52,7 +52,16 @@ impl App for RatingService {
&self.ctx.http_client,
)
.await
.map_err(|_| Status::unknown("Internal server error"))?;
.map_err(|e| {
let mut err = &e as &dyn Error;
let mut error = format!("{err}");
while let Some(src) = err.source() {
error.push_str(&format!("\n\nCaused by: {src}"));
err = src;
}
error!(%error, "unable to fetch snap name");
Status::unknown("Internal server error")
})?;

Ok(Response::new(GetRatingResponse {
rating: Some(PbRating {
Expand Down

0 comments on commit ddde201

Please sign in to comment.