|
4 | 4 | using System.Linq;
|
5 | 5 | using System.Net;
|
6 | 6 | using Common;
|
| 7 | +using Microsoft.Build.Logging; |
7 | 8 | using Microsoft.Extensions.Logging;
|
8 | 9 |
|
9 | 10 | namespace Commands
|
@@ -35,11 +36,17 @@ public static void UpdateIfOld()
|
35 | 36 | if (diff <= TimeSpan.FromHours(5))
|
36 | 37 | return;
|
37 | 38 | isAutoUpdate = true;
|
38 |
| - new SelfUpdate().Run(new[] {"self-update"}); |
| 39 | + var exitCode = new SelfUpdate().Run(new[] {"self-update"}); |
| 40 | + if (exitCode != 0) |
| 41 | + { |
| 42 | + Log.LogError("Auto update cement failed. 'self-update' exited with code '{Code}'", exitCode); |
| 43 | + ConsoleWriter.WriteWarning("Auto update failed. Check previous warnings for details"); |
| 44 | + } |
39 | 45 | }
|
40 | 46 | catch (Exception exception)
|
41 | 47 | {
|
42 |
| - Log.LogError("Fail to auto update", exception); |
| 48 | + Log.LogError("Auto update failed, error: '{Exception}'", exception); |
| 49 | + ConsoleWriter.WriteWarning("Auto update failed. Check logs for details"); |
43 | 50 | }
|
44 | 51 | }
|
45 | 52 |
|
@@ -187,21 +194,21 @@ private bool UpdateBinaries(ICementUpdater updater, string oldHash, string newHa
|
187 | 194 | Log.LogDebug(okMessage);
|
188 | 195 | return true;
|
189 | 196 | }
|
190 |
| - catch (WebException ex) |
| 197 | + catch (WebException webException) |
191 | 198 | {
|
192 |
| - Log.LogError("Fail self-update", ex); |
| 199 | + Log.LogError("Fail self-update, exception: '{Exception}'", webException); |
193 | 200 |
|
194 |
| - if (ex.Status == WebExceptionStatus.ProtocolError && ex.Response != null) |
| 201 | + if (webException.Status == WebExceptionStatus.ProtocolError && webException.Response != null) |
195 | 202 | {
|
196 |
| - var resp = (HttpWebResponse) ex.Response; |
| 203 | + var resp = (HttpWebResponse) webException.Response; |
197 | 204 | if (resp.StatusCode == HttpStatusCode.NotFound) // HTTP 404
|
198 | 205 | {
|
199 |
| - ConsoleWriter.WriteError($"Failed to look for updates on branch {branch}. Server responsed 404 ({updater.GetName()})"); |
| 206 | + ConsoleWriter.WriteWarning($"Failed to look for updates on branch {branch}. Server replied 404 ({updater.GetName()})"); |
200 | 207 | return false;
|
201 | 208 | }
|
202 | 209 | }
|
203 | 210 |
|
204 |
| - ConsoleWriter.WriteError($"Failed to look for updates on branch {branch}. {ex.Message} ({updater.GetName()})"); |
| 211 | + ConsoleWriter.WriteWarning($"Failed to look for updates on branch {branch}. {webException.Message} ({updater.GetName()})"); |
205 | 212 | return false;
|
206 | 213 | }
|
207 | 214 | }
|
|
0 commit comments