From 6e2a905f0511952aad06f4206196dbc034f5fa4e Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Mon, 27 Jan 2020 18:39:16 +0100 Subject: [PATCH] Cleanup ignored exceptions --- lib/core/git_repo.dart | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/lib/core/git_repo.dart b/lib/core/git_repo.dart index 49d0cb5a..f40ab872 100644 --- a/lib/core/git_repo.dart +++ b/lib/core/git_repo.dart @@ -118,28 +118,24 @@ class GitNoteRepository { } } +const ignoredMessages = [ + 'connection timed out', + 'failed to resolve address for', + 'failed to connect to', + 'no address associated with hostname', + 'unauthorized', + 'invalid credentials', + 'failed to start ssh session', + 'failure while draining', + 'network is unreachable', +]; + bool shouldLogGitException(GitException ex) { var msg = ex.cause.toLowerCase(); - if (msg.contains("failed to resolve address for")) { - return false; - } - if (msg.contains("failed to connect to")) { - return false; - } - if (msg.contains("no address associated with hostname")) { - return false; - } - if (msg.contains("failed to connect to")) { - return false; - } - if (msg.contains("unauthorized")) { - return false; - } - if (msg.contains("invalid credentials")) { - return false; - } - if (msg.contains("failed to start ssh session")) { - return false; + for (var i = 0; i < ignoredMessages.length; i++) { + if (msg.contains(ignoredMessages[i])) { + return false; + } } return true; }