Remora.Discord icon indicating copy to clipboard operation
Remora.Discord copied to clipboard

Improve GatewayError printing

Open MazeXP opened this issue 2 years ago • 4 comments

I just extended the GatewayError handling in the DiscordGatewayClient to also print the inner error to console.

This shows for example the cause why the gateway endpoint was not able to get.

MazeXP avatar Aug 26 '22 21:08 MazeXP

This is good, but I think a better option is to improve the pretty-printing of all errors in Remora.Results, then just use that.

Nihlus avatar Aug 27 '22 09:08 Nihlus

I see your point. I suppose printing the error chain associated with a result would be to first to tackle.

My idea for pretty printing would be as follows:

Result? result = ...;
int indentLevel = 0
while (result is not null && !result.IsSuccess) {
    foreach (var property in result.Error.Properties) { // Properties = Public Properties of Error Type
        PrintIdented(indentLevel, $"{property.Name} = {property.Value}");
    }
    result = result.Inner;
    indentLevel++;
}

MazeXP avatar Aug 27 '22 20:08 MazeXP

I agree, it would be nice if Remora.Results could pretty print all errors for us to our logs (but have us have to pass in the logger to use).

AraHaan avatar Sep 01 '22 18:09 AraHaan

Yep, this sounds good. Can you open an issue on Remora.Results and reference it here?

Nihlus avatar Sep 02 '22 17:09 Nihlus

Going to close this and refocus the idea onto Remora.Results.

Nihlus avatar Sep 26 '22 18:09 Nihlus