Pulls out the With* methods, and a couple of others to the Notifier type.
Advantages to this approach
Prevents import pollution of this package. The user can import the github.com/kinbiko/bugsnag package in one file, and pass it to other types via dependency injection + interfaces.
More future proof, as new features in the Notifier type are now available on most of the API. E.g. Deserialize can now call the InternalErrorCallback which is user-injected, and only available on the *Notifier.
Disadvantages to this approach
Tempts the user into creating a global Notifier (in their package), so that they can access these methods which really don't need to be methods, instead of directly accessing the methods from the bugsnag package.
Notably not included in this, is deleting the package-level Wrap function.
The reasoning here is that in a service-organised application, context information would most likely be attached at the method (≠function) level, before calling into other service methods, propagating the context. Errors on the other hand may occur at any level, and being able to call Wrap in a package level ('static') function without forcing the users to pass the notifier around everywhere is worth it in order to get the lowest possible stackframes. Context data, on the other hand, are most likely identical higher up the stack, and the error can be notified/re-wrapped at this point.
Pulls out the
With*
methods, and a couple of others to theNotifier
type.Advantages to this approach
github.com/kinbiko/bugsnag
package in one file, and pass it to other types via dependency injection + interfaces.InternalErrorCallback
which is user-injected, and only available on the*Notifier
.Disadvantages to this approach
Notably not included in this, is deleting the package-level Wrap function. The reasoning here is that in a service-organised application, context information would most likely be attached at the method (≠function) level, before calling into other service methods, propagating the context. Errors on the other hand may occur at any level, and being able to call Wrap in a package level ('static') function without forcing the users to pass the notifier around everywhere is worth it in order to get the lowest possible stackframes. Context data, on the other hand, are most likely identical higher up the stack, and the error can be notified/re-wrapped at this point.