authgear / authgear-server

Open source alternative to Auth0 / Firebase Auth
https://www.authgear.com
Apache License 2.0
81 stars 37 forks source link

Refactor api error #4074

Open louischan-oursky opened 5 months ago

louischan-oursky commented 5 months ago

Problem 1: The presence of skyerr and APIError

Remove skyerr and use APIError

Problem 2: APIError is not errors friendly

For example, APIError does not Unwrap, nor it supports errors.Is. This causes us to use custom functions like apierrors.IsKind or IsRateLimitErrorWithBucketName to compare error. Example of bugs: https://github.com/authgear/authgear-server/commit/6b660e8eb60572ddc5b1d089a912be051dc15823

Problem 3: some features in errorutil duplicate with errors

For example, errorutil.Unwrap, which can be replaced by errors.Is and errors.As. errorutil.WithSecondaryError, which can be replaced by errors.Join.

linear[bot] commented 5 months ago

DEV-1184 Refactor api error

fungc-io commented 5 months ago

@louischan can you provide more context to help me evaluate the priority of this issue? Like how are the users (or who) affected, severity, and how complicated to fix?

louischan-oursky commented 5 months ago

Mainly, we (the developer of Authgear) will be affected. The problems will cause us to introduce bugs, like in this example I mentioned. It takes about 5 points to fix.