Ephenodrom / Dart-Acme-Client

ACME client written in Dart.
MIT License
3 stars 5 forks source link

better way to get errors out of acme client #9

Open bsutton opened 11 months ago

bsutton commented 11 months ago

The AcmeClient.validate method has been returning an 'invalid' message.

This left me a little perplexed as I had no idea why the request was invalid.

In digging into the code I realised the problem was a firewall configuration.

The problem is that currently there is no way to get the 'root' error out of acme client.

I had a play with the response object returned from the second call to Dil().post in AcmeClient.validate and found that the error was contained in:

response!.data['challenges'][0]['error']['detail']

"34.69.220.126: Fetching http://xxxxxx/.well-known/acme-challenge/-F7yZhEiUqqRgra8wcEaLUG01jq_A3TH4RbBJ63Q-JU: Timeout d…"

So this error makes it fairly clear what the problem is but it isn't very friendly to make the user dig through code to determine the problem.

I had a look at adding a field 'lastResponse' to the AcmeClient which exposes the error but it isn't an adequate solution as you have to know to dig into the 4 levels of the response map.

Is there a better solution for this?

bsutton commented 11 months ago

So it turns out I had already raised an issue.

I'm not familiar enough with the RFC to understand all of the places we need to extract errors from. We also need to consider how we surface those errors. I would normally throw a custom exception but the current code based doesn't really use exceptions.

Suggestions?

bsutton commented 11 months ago

This is probably the last big issue that needs to be resolved to make the package perfect.

I'm not going to have the time to look at this any time soon so if anyone else wants to have a crack at it.