Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing with error:nil calls success callback rather than error callback #10

Open
Voxar opened this issue Jul 26, 2016 · 4 comments
Open

Comments

@Voxar
Copy link

Voxar commented Jul 26, 2016

Example below calls the completion callback but not the error callback. Is this by design?

[[[SPTask failedTask:nil] addCallback:^(id value) {
    NSLog(@"Called");
}] addErrorCallback:^(NSError *error) {
    NSLog(@"Not called");
}];
@nevyn
Copy link
Owner

nevyn commented Aug 17, 2016

Err it does‽ That certainly sounds like a really bad bug! Did you figure out why..?

@dflems
Copy link

dflems commented Feb 10, 2018

Not sure if anyone cares about this 1.5 year old issue anymore... but it's because failWithError: is expecting a non-nil value. In addCallback: the callback fires right away if the task is completed, and doesn't have an error set. Since error was nil it thinks you've completed without an error and it fires the callback.

It's technically against the API contract to provide a nil value as an error, but a quick fix would be to create a generic error object in the event that failWithError:nil is called. If you do that, the error callback will fire as-expected.

@nevyn: I'm not sure how much you use this library nowadays. We've made a lot of changes and cleanups on our internal fork and could kick those back upstream if you'd like.

@nevyn
Copy link
Owner

nevyn commented Mar 19, 2018

@dflems I use it in production every day, still! I just suck at github notifications. I would love to incorporate your changes!

Do you like the library in general? :D

@nevyn
Copy link
Owner

nevyn commented May 22, 2019

@dflems I'm still interested in those downstream changes, if you're willing :) I'm still using SPTask daily!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants