planFeatureDeniedFailure function

FailureException planFeatureDeniedFailure(
  1. ProcurementDeniedException e,
  2. StackTrace s, {
  3. required PlanFeature feature,
  4. required String projectId,
  5. required String failureMessage,
})

Maps a ProcurementDeniedException to the failure shown to the user.

A denial because the plan of projectId does not include feature becomes a failure with the server message and the plan upgrade hint. Any other denial becomes a nested failure with failureMessage.

Implementation

FailureException planFeatureDeniedFailure(
  final ProcurementDeniedException e,
  final StackTrace s, {
  required final PlanFeature feature,
  required final String projectId,
  required final String failureMessage,
}) {
  if (e.reason != ProcurementDeniedReason.productNotAvailable) {
    return FailureException.nested(e, s, failureMessage);
  }

  return FailureException(
    error: e.message,
    hint: feature.upgradeHint(projectId),
  );
}