Merge nucleic/olive-jade-civet-rznt into dev
This commit is contained in:
@@ -570,11 +570,21 @@ internal static class Program
|
||||
{
|
||||
if (e is null) return "an unknown error";
|
||||
var code = e is COMException com ? com.HResult : e.HResult;
|
||||
// COM messages from this API are often empty, which leaves a bare hex code and no clue.
|
||||
var message = string.IsNullOrWhiteSpace(e.Message) ? KnownHResult(code) : e.Message.Trim();
|
||||
// COM messages from this API are often empty, which leaves a bare hex code and no clue —
|
||||
// and when they are NOT empty they tend to arrive twice, because a WinRT failure carries
|
||||
// the text in both the restricted-error-info and the HRESULT message. Collapse both cases.
|
||||
var message = string.IsNullOrWhiteSpace(e.Message) ? KnownHResult(code) : OneLine(e.Message);
|
||||
return $"{e.GetType().Name} (0x{code:X8}): {message}";
|
||||
}
|
||||
|
||||
/// Fold a multi-line, often-duplicated exception message onto one line.
|
||||
private static string OneLine(string message) =>
|
||||
string.Join(" — ", message
|
||||
.Split('\r', '\n')
|
||||
.Select(line => line.Trim())
|
||||
.Where(line => line.Length > 0)
|
||||
.Distinct());
|
||||
|
||||
/// The codes actually seen coming out of wslc, decoded. The WSLC_E_* range is documented in
|
||||
/// `wslc.idl`; the other two are ordinary Windows errors that mean very different things and
|
||||
/// are easy to confuse — "not registered" is *nothing installed*, "not supported" is
|
||||
|
||||
Reference in New Issue
Block a user