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
This commit is contained in:
Mark Thomas 2020-09-21 08:35:15 -07:00 committed by Facebook GitHub Bot
parent 5d8357a30a
commit b6a6882d10
2 changed files with 10 additions and 6 deletions

View File

@ -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(),
));
}

View File

@ -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(),
));
}