ribesg
02/22/2019, 9:24 AMError
protocol in the ios part of my MPP project? NOT NSError
svyatoslav.scherbina
02/22/2019, 9:33 AMribesg
02/22/2019, 10:17 AMsvyatoslav.scherbina
02/22/2019, 11:48 AMI have a hard time with the “no inheritance under an ObjC/Swift class”What do you mean?
ribesg
02/22/2019, 12:50 PMBugsnagError
class which would be the super class of all our errors and in which we could add metadata to appear on the Bugsnag interface.
It’s not possible easily because the iOS BugsnagError
class cannot both be open
and extend NSError
. I can have it embed a NSError
, but then it cannot be thrown from Swift because it does not implement the Error
protocol.extension BugsnagError: Error {}
in the app using the lib...svyatoslav.scherbina
02/22/2019, 1:36 PMNSError
instead.ribesg
02/22/2019, 2:01 PMsvyatoslav.scherbina
02/22/2019, 2:14 PMNSError
can contain arbitrary data in userInfo
dictionary. So you can throw NSError
containing BugsnagError
instance.ribesg
02/22/2019, 2:39 PMuserInfo
is final and can’t be modified after the NSError
is created. That prevents me from having a nice feature: adding metadata to an error after it has been created. Typically, I would add call-site information to an error returned by a webservice implementation before sending it to the logger. I don’t think we can work without that feature... I could wrap an error in another one every time I add data to it but then the code retrieving this data before sending it to bugsnag needs to become recursive and take duplicates into account... It makes a lot of things much hardersvyatoslav.scherbina
02/22/2019, 3:06 PMBugsnagError
was an Error
, you would throw it.
It is not, so you can
* Throw NSError(userInfo: { "BugsnagError" : bugsnagError })
instead of bugsnagError
* Check that NSError
has "BugsnagError"
key instead of checking that error is BugsnagError
* Modify NSError.userInfo["BugsnagError"]
object instead of modifying a caught error directly.
How can this make some code recursive? You can handle special NSError
the same way you’d handle BugsnagError
.ribesg
02/22/2019, 3:14 PMNSError.userInfo["BugsnagError"]
? I thought userInfo
was a val
svyatoslav.scherbina
02/22/2019, 3:23 PMNSError.userInfo["BugsnagError"]
, i.e. the object from userInfo
.ribesg
02/22/2019, 4:08 PMBugsnagError
instance, like calling methods on it etc, but not replace itsvyatoslav.scherbina
02/22/2019, 5:25 PM