Skip to content

Commit

Permalink
Add ErrorTags for DiceErrors
Browse files Browse the repository at this point in the history
Summary: ^ makes it easier to spot DiceErrors when we encounter them

Reviewed By: JakobDegen

Differential Revision: D68188049

fbshipit-source-id: 01ccc029f7deb4529f78e87a0c3926a86695d326
  • Loading branch information
Will-MingLun-Li authored and facebook-github-bot committed Jan 15, 2025
1 parent 8b8657f commit bd27e0c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
9 changes: 9 additions & 0 deletions app/buck2_data/error.proto
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,15 @@ enum ErrorTag {
RE_DATA_LOSS = 1315;
RE_UNAUTHENTICATED = 1316;

// Dice Errors
// Value: https://fburl.com/code/5dxzaw41
DICE_DUPLICATED_CHANGE = 1400;
DICE_CHANGED_TO_INVALID = 1401;
DICE_INJECTED_KEY_GOT_INVALIDATION = 1402;
DICE_CANCELLED = 1403;
DICE_UNEXPECTED_CYCLE_GUARD_TYPE = 1404;
DICE_DUPLICATE_ACTIVATION_DATA = 1405;

// Error during attribute configuration during target configuration.
CONFIGURE_ATTR = 3001;
// Action execution
Expand Down
6 changes: 6 additions & 0 deletions app/buck2_error/src/classify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ pub(crate) fn category_and_rank(tag: ErrorTag) -> (Option<Tier>, u32) {
ErrorTag::HttpServer => rank!(tier0),
ErrorTag::StarlarkInternal => rank!(tier0),
ErrorTag::ActionMismatchedOutputs => rank!(tier0),
ErrorTag::DiceDuplicatedChange => rank!(tier0),
ErrorTag::DiceChangedToInvalid => rank!(tier0),
ErrorTag::DiceInjectedKeyGotInvalidation => rank!(tier0),
ErrorTag::DiceCancelled => rank!(tier0),
ErrorTag::DiceUnexpectedCycleGuardType => rank!(tier0),
ErrorTag::DiceDuplicateActivationData => rank!(tier0),

ErrorTag::Environment => rank!(environment),
ErrorTag::Tier0 => rank!(tier0),
Expand Down
21 changes: 20 additions & 1 deletion app/buck2_error/src/conversion/dice_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,29 @@
* of this source tree.
*/

use dice_error::DiceErrorImpl;

use crate::ErrorTag;

impl From<dice_error::DiceError> for crate::Error {
#[cold]
#[track_caller]
fn from(value: dice_error::DiceError) -> Self {
crate::conversion::from_any_with_tag(value, crate::ErrorTag::Tier0)
let error_tag = match *value.0 {
DiceErrorImpl::DuplicateChange(_) => ErrorTag::DiceDuplicatedChange,
DiceErrorImpl::ChangedToInvalid(_) => ErrorTag::DiceChangedToInvalid,
DiceErrorImpl::InjectedKeyGotInvalidation(_) => {
ErrorTag::DiceInjectedKeyGotInvalidation
}
// TODO(minglunli): Might be worth extracting the CancellationReason and create tags for those too
DiceErrorImpl::Cancelled(_) => ErrorTag::DiceCancelled,
DiceErrorImpl::UnexpectedCycleGuardType {
expected_type_name: _,
actual_type_name: _,
} => ErrorTag::DiceUnexpectedCycleGuardType,
DiceErrorImpl::DuplicateActivationData => ErrorTag::DiceDuplicateActivationData,
};

crate::conversion::from_any_with_tag(value, error_tag)
}
}

0 comments on commit bd27e0c

Please sign in to comment.