kinde-oss / kinde-dotnet-sdk

Kinde SDK for .Net
MIT License
14 stars 5 forks source link

Feature request: SDK Exception Handling #22

Open DevEnable opened 5 hours ago

DevEnable commented 5 hours ago

Prerequisites

What is the problem you’re trying to solve?

I think the current approach that Kinde has towards exception management in that SDK could do with some improvement. Here's Kinde's code when authentication fails.

if (!response.IsSuccessStatusCode || string.IsNullOrEmpty(content))
            {
                throw new ApplicationException("Invalid response from server: No token received");
            }

There's two issues with this:

For my purposes I'm mainly concerned with issue 1. I can live with the ApplicationException issue but I suspect it might cause downstream issues for Kinde, particularly with enterprise .NET customers as they tend to have more stringent standards reinforced by static code analysis.

What solution would you like to see?

As per the problem.

Additional information

No response

DevEnable commented 5 hours ago

As an example, over the last couple of days I have been troubleshooting an issue as to why I couldn't authenticate. I was able to replicate the issue with Postman (which I needed to fall back on as there was no easy way to do it), and then eventually I dug up the repository to look at the code and was able also replicate the same issue in .NET.

The only way to actually troubleshoot right now is via a debugger. Which doesn't leave a lot of confidence in supporting a Kinde solution in production.