agola-io / agola

Agola: CI/CD Redefined
https://agola.io
Apache License 2.0
1.47k stars 116 forks source link

errors: split wrapped error from APIError message #505

Closed sgotti closed 2 months ago

sgotti commented 2 months ago

Now, to add a message to an APIError, we had to wrap the starting error with errors.Wrap or, in case of no starting error, we had to create a new error with errors.Errorf.

This way isn't really clean since we are creating an intermediary wrapping error.

With this patch NewAPIError could be used when there's no error to wrap or the wrapped error can be provided using NewAPIErrorWrap. An optional message could be added using the WithAPIErrorMsg option.