Closed msisinni closed 1 year ago
Here's the associated issue I raised https://github.com/bugsnag/bugsnag-flutter/issues/186
Also note that I'm hoping you all will figure out why error.stacktrace
is empty in the first place and fix that on your own, assuming that it's really not supposed to be empty. If it's allowed to be empty, then you all should double check your library for places where you call things like .first
and .firstWhere
, since those will throw errors on empty lists.
HI @msisinni, Thanks for this. As mentioned on https://github.com/bugsnag/bugsnag-flutter/issues/186#issuecomment-1346213128 we're going to do some digging on our side on this. I'll leave the PR open for now awaiting the outcome of that investigation.
Fix released in BugSnag Flutter v2.5.0
Goal
StateErrors were being thrown from calling .first on an empty list in the method
Future<BugsnagEvent?> _createEvent(
.Design
buildID
is nullable anyway. bugsnag probably expected it'd be null because it's null on the first element oferror.stacktrace
instead of fromerror.stacktrace
being empty. If you all want to fix it a different way, that's fine. This PR can just help point out what's wrong. Also, if you don't want the import for'package:collection/collection.dart';
, you can change it something else likeChangeset
I used a method from collection.dart that doesn't cause StateErrors when trying to get the first element of a List. Because that method can return null, I added
?
before.codeIdentifier
. Also I removedimport 'dart:ui';
because it was unused.Testing
I tested throwing deliberate errors in my app locally and saw that they were successfully reported to bugsnag. Then I switched my production app to using my forked copy of the bugsnag_flutter repo.