Closed Eathox closed 2 years ago
At the risk of getting ahead of myself, I have thought about some potential implementations. I'm not confident on what a good approach would be as some of the values are already reserved by this library.
I originally was thinking of adding a 5x return, where x would be the custom returnCode. But I think this is kinda a pain since I can imagine I'd be nice too easily tell if it's an extension implemented returnCode purely based on its value range. So with that in mind maybe It would be nicer to utilise the entire negative range for custom returnCode's?
I think this could be handled with Rust's result, and returning 9
to indicate an application error.
(this is pseudo code and not recommended, use callbacks for async operations like api calls)
fn fetch_something() -> Result<String, String> {
fetch("https://example.api/my_data").map_err(|e| format!("Unable to fetch data: {:?}", e))
}
A successful call would return ["some api data", 0, 0]
, while a failed call would look like ["Unable to fetch data: some error", 9, 0]
This way you can easily check for an application error, and send whatever type of error you'd like back to SQF
Heyo, I'm working on an extension which I was original developing in c++ but recently decided to switch to rust (partially because of this library :D). The old (c++) version of the extension utilised the ability to both be able to return a result and returnCode to represent custom errors.
From what I can see this library currently does not support the ability to return an extension specific returnCode. So I was wondering if the ability to do so could be considered.