feat: add more context to message loading errors

This commit is contained in:
link2xt
2023-05-16 10:31:25 +00:00
parent 2e6f98f4e4
commit f9dc8edbcb
2 changed files with 18 additions and 8 deletions

View File

@@ -537,7 +537,9 @@ impl Message {
/// Returns the size of the file in bytes, if applicable.
pub async fn get_filebytes(&self, context: &Context) -> Result<Option<u64>> {
if let Some(path) = self.param.get_path(Param::File, context)? {
Ok(Some(get_filebytes(context, &path).await?))
Ok(Some(get_filebytes(context, &path).await.with_context(
|| format!("failed to get {} size in bytes", path.display()),
)?))
} else {
Ok(None)
}