api: provide an error when the output does not exist where to add an tag#425
api: provide an error when the output does not exist where to add an tag#425xMAC94x wants to merge 1 commit intopinnacle-comp:mainfrom
Conversation
7b21dcb to
9009721
Compare
| let error = response.error.and_then(|error| error.kind); | ||
| match error { | ||
| None => Ok(response.tag_ids.into_iter().map(|id| TagHandle { id })), | ||
| Some(AddErrorKind::OutputDoesNotExist(_)) => Err(AddError::OutputDoesNotExist), |
There was a problem hiding this comment.
It feels kind of weird. The api gets a OutputHandle and we can prob always expect the outputHandle to actually map to an existing Output.
It feels weird that you have to check on that error as user again. Maybe its okay to just tracing::error() or expect in this case.
The same goes for move_to_output when the output is provided via a handle.
WDYT ?
There was a problem hiding this comment.
The api gets a OutputHandle and we can prob always expect the OutputHandle to actually map to an existing Output.
The OutputHandle could be stale or become stale sometime between calling this function and the server receiving the message. We can't do any assumption on the validity of the data (beside, user input should not be trusted, so let's not assume anything).
It feels weird that you have to check on that error as user again. Maybe its okay to just tracing::error() or expect in this case.
IMO the API should never hide or consume errors, unless the "error" is an expected case and a documented fallback behavior exists (and even then the calling code should be notified).
There was a problem hiding this comment.
in that case I think the PR is good to go
a61a97e to
94cb3ab
Compare
94cb3ab to
5a4e23a
Compare
|
@Ph4ntomas @Ottatop PR is ready for review |
|
After giving this some thought, my main concern is that returning an error introduces a bit more friction when using this API. Yes, if we really wanted to be "correct" here we would add this. However, there are also a slew of methods on the other With I'm not saying returning a result here is useless, but I'm not convinced that the upside is large enough to warrant the change. For example, yes, |
Just my 2c here. Most of the time, errors will end up in the log file by the server. This is more that okay for now, but IMO it's confusing for user not to have any kind of (visual) feedback. OTOH keeping the API simple is nice. My proposition would be:
¹ At some point, we could log errors/warning coming from the server in non-failible function by calling |
I considered this, but my concern here is that we have to expose a second fallible function for everything that can fail, which is... a lot of things. Well, we don't have to, but again, where do we draw the line? Also, seeing as this doubles the function count and how there are already functions duplicated for async-ness on the Rust side, that would be 4 slightly different functions for the same thing. Also also, same thing with just making the function return an error, how useful is it going to be? Turning to this PR, realistically what is someone going to do if they encounter an Looking at prior arts, Jay has a Rust config and doesn't appear to return a lot of errors. Actually that API seems to go in the complete opposite direction and encodes null/invalid states within objects to make a lot of functions infallible. Awesome's tag.add also appears to be infallible. Not actually sure if that just returns
This is an interesting idea. While I feel exposing all the errors has ergonomic issues, better visibility of the errors that do occur is a good middle ground. But obviously that's out-of-scope here and needs further discussion. |
|
I can totally understand all of those concerns. I am not sure which approach is the right one tbh. However I want that error handling is kinda similar across the API. I you want me, I can adjust this MR to be
|
|
Let's hold off on that until we figure out how we're actually going to use the errors, no point in implementing that now if plans change later |
similar to the error for
move_to_output