From b6a6882d1090ad55f025abd6ca6ce7028772295e Mon Sep 17 00:00:00 2001 From: Mark Thomas Date: Mon, 21 Sep 2020 08:35:15 -0700 Subject: [PATCH] improve error messages for mapping length errors Summary: Make it clear which error is which, and what the number of expected and actual items are. Reviewed By: StanislavGlebik Differential Revision: D23813369 fbshipit-source-id: 5b94c5a67438c475235876669ec2be3fd1866700 --- .../bonsai_git_mapping/git_mapping_pushrebase_hook/lib.rs | 8 +++++--- .../globalrev_pushrebase_hook/lib.rs | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/eden/mononoke/bonsai_git_mapping/git_mapping_pushrebase_hook/lib.rs b/eden/mononoke/bonsai_git_mapping/git_mapping_pushrebase_hook/lib.rs index 54b1155cad..61ee24b755 100644 --- a/eden/mononoke/bonsai_git_mapping/git_mapping_pushrebase_hook/lib.rs +++ b/eden/mononoke/bonsai_git_mapping/git_mapping_pushrebase_hook/lib.rs @@ -5,7 +5,7 @@ * GNU General Public License version 2. */ -use anyhow::Error; +use anyhow::{anyhow, Error}; use async_trait::async_trait; use bookmarks::BookmarkTransactionError; use context::CoreContext; @@ -97,8 +97,10 @@ impl PushrebaseCommitHook for GitMappingCommitHook { // NOTE: This check shouldn't be necessary as long as pushrebase hooks are bug-free, but // since they're a new addition, let's be conservative. if rebased.len() != self.assignments.len() { - return Err(Error::msg( - "Rebased set and assignments have different lengths!", + return Err(anyhow!( + "Git mapping rebased set ({}) and assignments ({}) have different lengths!", + rebased.len(), + self.assignments.len(), )); } diff --git a/eden/mononoke/bonsai_globalrev_mapping/globalrev_pushrebase_hook/lib.rs b/eden/mononoke/bonsai_globalrev_mapping/globalrev_pushrebase_hook/lib.rs index 1be9524e14..a5d7771065 100644 --- a/eden/mononoke/bonsai_globalrev_mapping/globalrev_pushrebase_hook/lib.rs +++ b/eden/mononoke/bonsai_globalrev_mapping/globalrev_pushrebase_hook/lib.rs @@ -5,7 +5,7 @@ * GNU General Public License version 2. */ -use anyhow::Error; +use anyhow::{anyhow, Error}; use async_trait::async_trait; use bookmarks::BookmarkTransactionError; use context::CoreContext; @@ -124,8 +124,10 @@ impl PushrebaseCommitHook for GlobalrevCommitHook { // NOTE: This check shouldn't be necessary as long as pushrebase hooks are bug-free, but // since they're a new addition, let's be conservative. if rebased.len() != self.assignments.len() { - return Err(Error::msg( - "Rebased set and assignments have different lengths!", + return Err(anyhow!( + "Globalrev rebased set ({}) and assignments ({}) have different lengths!", + rebased.len(), + self.assignments.len(), )); }