mxcl / PromiseKit

Promises for Swift & ObjC.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

crash inside `Error.isCanceled` (instance of #649)

krypt-lynx opened this issue · comments

Following request to open new issue left in issue #649

I caused this issue by following code:

    .then { _ -> Promise<Void> in
        throw NSError()
    }

for whatever reason, swift allows to create empty NSError (frankly, looks like a bug, there is no empty constructor defined for NSError in Swift)

version: 6.13.1 installed using CocoaPods

Not really sure what to say except either:

  1. Don’t do that
  2. Report it to Apple

As far as I know our code is legal Swift that shouldn’t crash.

It actually isn't?
There is no default constructor for NSError:
https://developer.apple.com/documentation/foundation/nserror
Actually, I distinctly remember failing to create empty NSError before (as in syntax error), so, it appears to be a resent Swift bug.
Maybe all other instances of #649 was similar bugs in NSError bridging?

If you can find a line of code in PromiseKit that is illegal we will correct it.

As it stands you are calling NSError(). If you can submit a PR to this repo that fixes your code in your repo, I will merge it.

I mean, it looks like it was a bit of the mystery to you, so, I decided to report one possible source of the issue 🤷‍♂️

As to my attempts to find the source of the issue (which was that NSError() in my experiments), I did not found a workaround before I found the source of troubles. And frankly, I don't see how one could be possible. Your code should work, this the a legal way to do things.

K, thanks. This is the issue tracker, so if it's not a bug I will move this to the discussions board.