How do we handle the custom errors returned from calling a function in the client side? here is my function:
pub fn create_resume(ctx: Context<CreateResume>, name: String, age: u8, skills: Vec<String>) -> Result<()>{
if name.len() > 20{
return err!(Error::ExceedsLimit)
}
if age > 100{
return err!(Error::ExceedsLimit)
}
if skills.len() > 10{
return err!(Error::ExceedsLimit)
}
for skill in skills.iter(){
if skill.len() > 10{
return err!(Error::ExceedsLimit)
}
}
let resume = &mut ctx.accounts.resume;
resume.wallet = ctx.accounts.signer.key();
resume.bump = *ctx.bumps.get("resume").unwrap();
resume.name = name;
resume.age = age;
resume.skills = skills;
Ok(())
}
The error that I have defined
#[error_code]
pub enum Error{
#[msg("Failed to verify authority")]
Unauthorized,
#[msg("Exceeds limit")]
ExceedsLimit,
#[msg("Skill doesn't exist")]
DoesNotExist,
}
How do I handle the error in the client side? can anyone show me an example?