solitaire: Mention invalid value in InvalidMutability
Change-Id: I240518737243eb7dabbf8ec31bd11148b4475832
This commit is contained in:
parent
9a85dbafe5
commit
f7979ee8b1
|
@ -12,8 +12,9 @@ pub type ErrBox = Box<dyn std::error::Error>;
|
||||||
/// There are several places in Solitaire that might fail, we want descriptive errors.
|
/// There are several places in Solitaire that might fail, we want descriptive errors.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum SolitaireError {
|
pub enum SolitaireError {
|
||||||
/// The AccountInfo parser expected a mutable key where a readonly was found, or vice versa.
|
/// The AccountInfo parser expected a mutable key where a readonly
|
||||||
InvalidMutability(Pubkey),
|
/// was found, or vice versa. Second item is the found value.
|
||||||
|
InvalidMutability(Pubkey, bool),
|
||||||
|
|
||||||
/// The AccountInfo parser expected a Signer, but the account did not sign.
|
/// The AccountInfo parser expected a Signer, but the account did not sign.
|
||||||
InvalidSigner(Pubkey),
|
InvalidSigner(Pubkey),
|
||||||
|
|
|
@ -69,7 +69,9 @@ impl<'a, 'b: 'a, 'c, T: Peel<'a, 'b, 'c>> Peel<'a, 'b, 'c> for Mut<T> {
|
||||||
ctx.immutable = false;
|
ctx.immutable = false;
|
||||||
match ctx.info().is_writable {
|
match ctx.info().is_writable {
|
||||||
true => T::peel(ctx).map(|v| Mut(v)),
|
true => T::peel(ctx).map(|v| Mut(v)),
|
||||||
_ => Err(SolitaireError::InvalidMutability(*ctx.info().key).into()),
|
_ => Err(
|
||||||
|
SolitaireError::InvalidMutability(*ctx.info().key, ctx.info().is_writable).into(),
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,7 +164,9 @@ where
|
||||||
impl<'a, 'b: 'a, 'c> Peel<'a, 'b, 'c> for Info<'b> {
|
impl<'a, 'b: 'a, 'c> Peel<'a, 'b, 'c> for Info<'b> {
|
||||||
fn peel<I>(ctx: &'c mut Context<'a, 'b, 'c, I>) -> Result<Self> {
|
fn peel<I>(ctx: &'c mut Context<'a, 'b, 'c, I>) -> Result<Self> {
|
||||||
if ctx.immutable && ctx.info().is_writable {
|
if ctx.immutable && ctx.info().is_writable {
|
||||||
return Err(SolitaireError::InvalidMutability(*ctx.info().key).into());
|
return Err(
|
||||||
|
SolitaireError::InvalidMutability(*ctx.info().key, ctx.info().is_writable).into(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(ctx.info().clone())
|
Ok(ctx.info().clone())
|
||||||
|
@ -187,7 +191,9 @@ impl<
|
||||||
{
|
{
|
||||||
fn peel<I>(ctx: &'c mut Context<'a, 'b, 'c, I>) -> Result<Self> {
|
fn peel<I>(ctx: &'c mut Context<'a, 'b, 'c, I>) -> Result<Self> {
|
||||||
if ctx.immutable && ctx.info().is_writable {
|
if ctx.immutable && ctx.info().is_writable {
|
||||||
return Err(SolitaireError::InvalidMutability(*ctx.info().key).into());
|
return Err(
|
||||||
|
SolitaireError::InvalidMutability(*ctx.info().key, ctx.info().is_writable).into(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're initializing the type, we should emit system/rent as deps.
|
// If we're initializing the type, we should emit system/rent as deps.
|
||||||
|
|
Loading…
Reference in New Issue