Skip to content

Commit

Permalink
5.3.0
Browse files Browse the repository at this point in the history
Took 37 minutes
  • Loading branch information
Drawner committed Oct 6, 2024
1 parent a21cfd9 commit 98d75fe
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

## 5.3.0
October 06, 2024
- getter, lastErrorMessage, in AppState class in part08_app_statex.dart

## 5.2.4
October 05, 2024
- Class, AppState, has lastFlutterError() to record and return
Expand Down
41 changes: 32 additions & 9 deletions lib/part08_app_statex.dart
Original file line number Diff line number Diff line change
Expand Up @@ -379,15 +379,18 @@ abstract class AppStateX<T extends StatefulWidget> extends StateX<T>
try {
//
_onError(details);
} catch (e) {
} catch (e, stack) {
// Throw in DebugMode.
if (kDebugMode) {
// Set the original error routine. Allows the handler to throw errors.
FlutterError.onError = _prevErrorFunc;
// Rethrow to be handled by the original routine.
rethrow;
} else {
// Record error in log
// Record the error
recordException(e, stack);

// Record error in device's log
_logPackageError(
e,
library: 'part08_app_statex.dart',
Expand Down Expand Up @@ -423,7 +426,7 @@ abstract class AppStateX<T extends StatefulWidget> extends StateX<T>
// The App's error handler
onError(details);

// its own Error handler
// If no App Error Handler, run its own Error handler
if (!_onErrorOverridden && _prevErrorFunc != null) {
_prevErrorFunc!.call(details);
}
Expand All @@ -432,23 +435,43 @@ abstract class AppStateX<T extends StatefulWidget> extends StateX<T>
_inErrorRoutine = false;
}

/// A flag indicating we're running in the error routine.
/// Set to avoid infinite loop if in errors in the error routine.
bool _inErrorRoutine = false;

/// Supply the last Flutter Error Details if any.
FlutterErrorDetails? get lastFlutterErrorDetails => _lastFlutterErrorDetails;

/// Record and return details of the 'last' handled error
/// Not, simply retrieving the last error will 'clear' the storage.
FlutterErrorDetails? lastFlutterError([FlutterErrorDetails? details]) {
FlutterErrorDetails? lastErrorDetails;
if (details == null) {
lastErrorDetails = _handledErrorDetails;
lastErrorDetails = _lastFlutterErrorDetails;
_lastFlutterErrorDetails = null; // Clear the storage for next time.
} else {
lastErrorDetails = _handledErrorDetails = details;
lastErrorDetails = _lastFlutterErrorDetails = details;
}
return lastErrorDetails;
}

// Record the details of the last error if any
FlutterErrorDetails? _handledErrorDetails;
FlutterErrorDetails? _lastFlutterErrorDetails;

/// A flag indicating we're running in the error routine.
/// Set to avoid infinite loop if in errors in the error routine.
bool _inErrorRoutine = false;
/// Return the message of th 'last' Flutter Error if any.
String get lastFlutterErrorMessage {
String message;
final details = _lastFlutterErrorDetails;
if (details == null) {
message = '';
} else {
message = details.exceptionAsString();
}
if (message.contains('<no message available>')) {
message = '';
}
return message;
}

/// Call the latest SateX object's error routine
/// Possibly the error occurred there.
Expand Down
4 changes: 3 additions & 1 deletion lib/part17_record_exception_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

part of 'state_extended.dart';

/// Record an exception
/// Record an exception for review by the developer
///
/// dartdoc:
/// {@category StateX class}
Expand Down Expand Up @@ -35,6 +35,8 @@ mixin RecordExceptionMixin on State {
Exception? _recException;

/// Simply display the exception.
String get exceptionMessage => errorMsg;
@Deprecated('Use exceptionMessage instead.')
String get errorMsg {
String message;
if (_recException == null) {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: state_extended
description: This class extends the capabilities of Flutter's State class and includes a controller.
version: 5.2.4
version: 5.3.0
homepage: https://www.andrioussolutions.com
repository: https://github.com/AndriousSolutions/state_extended

Expand Down

0 comments on commit 98d75fe

Please sign in to comment.