gear-tech / sails

Framework for ultimate experience of writing programs powered by Gear protocol
Apache License 2.0
17 stars 4 forks source link

feat(gservice): consider impl `#[panicking]` macro for fns in service #262

Open breathx opened 3 months ago

breathx commented 3 months ago

The macro will require Result in return type, but it only will be for ability to use ?. On expand it will unwrap() the result and return only Ok(T)

DennisInSky commented 3 months ago

@breathx can you please elaborate on this? Any examples of usage?

DennisInSky commented 1 month ago

@breathx better description is on you

fn mint(&nut self, value: u64) -> bool { ler r: Result<bool, String> = some_func(); r.unwrap(); // intentionally }

[panicking]

fn mint(&nut self, value: u64) -> Result<bool, String> { ler r: Result<bool, String> = some_func()?; }

vobradovich commented 1 month ago

Wouldn't it be better to use the existing route attribute with the unwrap_result prameter?

#[route(unwrap_result)]
fn mint(&nut self, value: u64) -> Result<bool, String> {
    ler r: Result<bool, String> = some_func()?;
}