Lachee / discord-rpc-csharp

C# custom implementation for Discord Rich Presence. Not deprecated and still available!
MIT License
561 stars 93 forks source link

Fix ConsoleLogger throwing FormatException #208

Closed jonashouben closed 1 year ago

jonashouben commented 1 year ago

Fixes #207.

The issue are this lines in RpcConnection. When either the Exception Message, or the Stacktrace contains a brace (for example "{").

grafik

I fixed it like in the FileLogger - only use the formatted version, when arguments are actually provided.

dowmeister commented 1 year ago

hey @jonashouben , thank you from the community :)

Are you able to reproduce? is it an error related to a Discord update or something? I've tried to reproduce but on many clients works correctly. Just curious to know from what is caused

jonashouben commented 1 year ago

hey @jonashouben , thank you from the community :)

Are you able to reproduce? is it an error related to a Discord update or something? I've tried to reproduce but on many clients works correctly. Just curious to know from what is caused

Unfortunately not. As written by others in the issue, it only happens for some users. But I'm relatively sure it's the exception message, because that's the only place in MainLoop where it can cause the logger to throw.

jonashouben commented 1 year ago

@shardick maybe to clarify. The PR is fixing only the logging, not the logged error :)

Lachee commented 1 year ago

Thank you for your contribution. The other loggers will be updated to match this before i push another release :)

jonashouben commented 1 year ago

Hey @Lachee, thanks!

As far as I noticed, the other loggers already have this behavior:

FileLogger: args.Length > 0 ? string.Format(message, args) : message NullLogger: Nothing logged

Phoenixx19 commented 1 year ago

Thanks! :)

Lachee commented 1 year ago

Thank you for your contribution. This is now released in v1.1.1 ✨🌟 🎉