From 4d4efaef15fd8396de5c6f0319263f6a44e5fbab Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Tue, 4 Jul 2017 14:30:56 -0400 Subject: [PATCH] Wraps UpdateServer with try/catch --- TGServerService/InterfaceBase.cs | 75 +++++++++++++++++--------------- 1 file changed, 41 insertions(+), 34 deletions(-) diff --git a/TGServerService/InterfaceBase.cs b/TGServerService/InterfaceBase.cs index 9b800f2c38..8179d2e688 100644 --- a/TGServerService/InterfaceBase.cs +++ b/TGServerService/InterfaceBase.cs @@ -40,48 +40,55 @@ namespace TGServerService //one stop update public string UpdateServer(TGRepoUpdateMethod updateType, bool push_changelog_if_enabled, ushort testmerge_pr) { - string res; - switch (updateType) + try { - case TGRepoUpdateMethod.Hard: - case TGRepoUpdateMethod.Merge: - res = Update(updateType == TGRepoUpdateMethod.Hard); + string res; + switch (updateType) + { + case TGRepoUpdateMethod.Hard: + case TGRepoUpdateMethod.Merge: + res = Update(updateType == TGRepoUpdateMethod.Hard); + if (res != null && res != RepoErrorUpToDate) + return res; + break; + case TGRepoUpdateMethod.Reset: + res = Reset(true); + if (res != null) + return res; + break; + case TGRepoUpdateMethod.None: + break; + } + + if (testmerge_pr != 0) + { + res = MergePullRequestImpl(testmerge_pr, true); if (res != null && res != RepoErrorUpToDate) return res; - break; - case TGRepoUpdateMethod.Reset: - res = Reset(true); + } + + GenerateChangelog(out res); + if (res != null) + return res; + + if (push_changelog_if_enabled && SSHAuth()) + { + res = Commit(); if (res != null) return res; - break; - case TGRepoUpdateMethod.None: - break; - } + res = Push(); + if (res != null) + return res; + } - if (testmerge_pr != 0) + if (!Compile(true)) + return "Compilation could not be started!"; + return null; + } + catch (Exception e) { - res = MergePullRequestImpl(testmerge_pr, true); - if (res != null && res != RepoErrorUpToDate) - return res; + return e.ToString(); } - - GenerateChangelog(out res); - if (res != null) - return res; - - if (push_changelog_if_enabled && SSHAuth()) - { - res = Commit(); - if (res != null) - return res; - res = Push(); - if (res != null) - return res; - } - - if (!Compile(true)) - return "Compilation could not be started!"; - return null; } //public api