Skip to content

[TASK] Improve type checking error #955

@Serial-ATA

Description

@Serial-ATA

Overview

When doing a job call, type checking is performed, and the cause of errors is known:

pub fn type_checker<C: Constraints, AccountId: Encode + Clone>(
params: &[FieldType],
args: &[Field<C, AccountId>],
) -> Result<(), TypeCheckError> {
if params.len() != args.len() {
return Err(TypeCheckError::NotEnoughArguments {
expected: params.len() as u8,
actual: args.len() as u8,
});
}
for i in 0..args.len() {
let arg = &args[i];
let expected = &params[i];
if arg != expected {
return Err(TypeCheckError::ArgumentTypeMismatch {
index: i as u8,
expected: expected.clone(),
actual: arg.clone().into(),
});
}
}
Ok(())
}

However, the error is then immediately converted to one with no information:

job_call.type_check(job_def).map_err(Error::<T>::TypeCheck)?;

We should retain the information from the original error, otherwise it isn't clear what's gone wrong.

Metadata

Metadata

Assignees

Type

Projects

Status

Not Started 🕧

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions