Commit a984aeac authored by Wilko Manger's avatar Wilko Manger

Fix sync error handling

parent bb9dd258
......@@ -34,8 +34,6 @@ class ErrorBannerState extends State<ErrorBanner>
AnimationController _controller;
Animation<double> _animation;
var isConnectionError = false;
@override
void initState() {
super.initState();
......@@ -61,10 +59,9 @@ class ErrorBannerState extends State<ErrorBanner>
stream: syncBloc.stream,
builder: (BuildContext context, AsyncSnapshot<SyncState> snapshot) {
final state = snapshot.data;
final error = state?.exception ?? snapshot.error;
final hasSucceeded = state != null && state.succeeded;
if (!hasSucceeded) {
if (error != null ) {
_controller.forward();
} else {
_controller.animateBack(0);
......@@ -72,15 +69,8 @@ class ErrorBannerState extends State<ErrorBanner>
Widget icon = Icon(Icons.cloud_off);
Widget text = Text(l(context).connectionLost);
if (state != null &&
(state.exception is SocketException
|| state.exception is http.ClientException)) {
isConnectionError = true;
} else if (state != null) {
isConnectionError = false;
}
if (state != null && !isConnectionError) {
if (error is! SocketException && error is! http.ClientException) {
// TODO: Make error messages less complex for end users,
// but keep it like this for now (before 1.0).
icon = Icon(Icons.bug_report);
......@@ -92,7 +82,7 @@ class ErrorBannerState extends State<ErrorBanner>
text: '${l(context).anErrorHasOccurred}\n'
),
TextSpan(
text: state.exception.toString(),
text: error.toString(),
style: TextStyle(
fontFamily: 'monospace',
fontWeight: FontWeight.bold
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment