// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////////
//! Error definitions for AuthMgr FE Trusty TA
#[derive(Debug)]
pub enum AuthMgrFeTrustyError {
AuthGraphError(authgraph_core::error::Error),
AuthMgrFeCoreError(authmgr_fe_core::error::Error),
BinderStatus(binder::StatusCode),
CoseError(coset::CoseError),
DiceError(diced_open_dice::DiceError),
PvmDiceError(pvmdice::PvmDiceError),
TipcError(tipc::TipcError),
UnknownError(&
'static str),
}
// It would be nice to use something like thiserror or anyhow,
// but to do so we'd need to go back and implement core::error::Error
// on a bunch of our error types.
macro_rules! impl_from {
($from_err:ty, $variant:ident) => {
impl From<$from_err>
for AuthMgrFeTrustyError {
fn from(e: $from_err) ->
Self {
Self::$variant(e)
}
}
};
}
impl_from!(authgraph_core::error::Error, AuthGraphError);
impl_from!(authmgr_fe_core::error::Error, AuthMgrFeCoreError);
impl_from!(binder::StatusCode, BinderStatus);
impl_from!(coset::CoseError, CoseError);
impl_from!(diced_open_dice::DiceError, DiceError);
impl_from!(tipc::TipcError, TipcError);
impl_from!(pvmdice::PvmDiceError, PvmDiceError);