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

defer / asynchronousFirstOrDefault in unit test seems to completely swallow exception output #1546

Closed
fatuhoku opened this issue Oct 26, 2014 · 3 comments

Comments

@fatuhoku
Copy link

I've run up against some nasty behaviour. I've got an async operation here:

-(RACSignal *)foobar {
    return [RACSignal defer:^RACSignal * {
        RACSignal *resultSignal = [RACSignal empty];

        @try{

            @[][3];               // exceptions' log outputs are silenced if I don't use @try block

            resultSignal = [RACSignal createSignal:...];
        } @catch(NSException *exc) {
            NSLog(@"%@", exc);    // the exception can be caught here, though.
        } @finally {
            return resultSignal
        }
    }];
}

... which I test against in unit tests in the following way:

NSArray *values = [[[AsyncOperation foobar] collect] asynchronousFirstOrDefault:@[] success:nil error:&error];  // HANGS here

My tests hangs on that line and errors out, but nothing informative is printed. This is terrible for debugging.

The only way I can find out what happened is to catch the exception and PRINT the information from the exception manually using a @Try block. This shouldn't need to be the case.

Why is this happening?

@jlawton
Copy link
Contributor

jlawton commented Oct 27, 2014

I get the exception in the console as normal when I run this on the main thread without the @try. The stack trace has 50-odd frames of RAC in it, but it seems fine.

@jspahrsummers
Copy link
Member

Exceptions are not supposed to be recoverable in Objective-C, so we don't make any attempt to support it.

@fatuhoku
Copy link
Author

Hmmm. It must be something else in my code. @jlawton you're right, the snippet I posted as it is works okay. But some almost identical code elsewhere in my codebase has its exceptions swallowed. Mysterious.

Thanks for now.

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