lambdaclass / cairo_native

A compiler to convert Cairo's intermediate representation "Sierra" code to MLIR.
https://lambdaclass.github.io/cairo_native/cairo_native
Apache License 2.0
111 stars 43 forks source link

Improve error handling #632

Open pefontana opened 3 months ago

pefontana commented 3 months ago

Improve the error handling in the repo Right now we have just one general error type, This is OK, https://vscode.dev/github/lambdaclass/cairo_native/blob/main/src/error.rs#L12-L13

But the enum variants inside use mostly strings or aren't so descriptive. We should create a new module for those error variants and use enums instead of strings to describe the error.

check errors

Error(String),
ParseAttributeError,
adrianvrj commented 3 months ago

Hey @pefontana I would love to work on this, could deliver it in 2 days!

danielcdz commented 3 months ago

Hey @pefontana I would like to help with this one, in the past I made contributions to Nethermind, this can take me about 1-2 days, as I already have some experience with Cairo

Utilitycoder commented 3 months ago
use std::{alloc::LayoutError, num::TryFromIntError};

#[derive(Error, Debug)]
pub enum Error {
    #[error(transparent)]
    LayoutError(#[from] crate::utils::LayoutError),

    #[error(transparent)]
    MlirError(#[from] melior::Error),

    #[error("missing parameter of type '{0}'")]
    MissingParameter(ParameterType),
}

pub enum ParameterType {
    TypeA,
    TypeB,
}

Is the above approach in line with the changes you have in mind for the error module? I agree that replacing string-based errors with structured and descriptive enum variants will enhance clarity.

od-hunter commented 2 months ago

Can i hop on this please?

pefontana commented 2 months ago

hi @od-hunter ! Yes sure! i will assign it to you

od-hunter commented 2 months ago

@pefontana , Sorry I have been assigned other issues already and Iā€™m working on them, in other not to disappoint you, kindly assign this to someone else, thank you šŸ™šŸ¾

gadyrcdz commented 1 month ago

Hi @pefontana, if this issue is still available I'd like to help!

adrianvrj commented 3 weeks ago

Hi, is this still open for contribution? If so, can I hop on this?

hart-venus commented 3 weeks ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

My background is in web development and low level systems, it can be leveraged to create effective and efficient error handling

How I plan on tackling this issue

I would approach the problem by identifying error types, sorting those into an enum then implementing them in rust, which would also need to be documented and written tests for.

RuneRogue commented 2 days ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a blockchain and DeFi developer . I am having experience of 8 months . I am currently working as a Blockchain Researcher and Developer. My Experience in programming language like Go , Rust , Java will help me to solve this issue.