firebase / firebase-admin-go

Firebase Admin Go SDK
Apache License 2.0
1.12k stars 239 forks source link

errorutils does not work with wrapped errors #556

Open Azuka opened 1 year ago

Azuka commented 1 year ago

[REQUIRED] Step 2: Describe your environment

[REQUIRED] Step 3: Describe the problem

Related to #416, a wrapped firebase internal error cannot be introspected

Steps to reproduce:

https://github.com/firebase/firebase-admin-go/blob/61c6c041bf807c045f6ff3fd0d02fc480f806c9a/internal/errors.go#L100

Relevant Code:

// err works with errorutils.IsNotFound
_, err := authClient.GetUserByEmail(ctx, "example@example.com")
// errorutils.IsNotFound doesn't work
err = fmt.Errorf("[AuthService] %w")

Solution

Use errors.As instead of a simple typecast. I can open a pull request right away.

google-oss-bot commented 1 year ago

I found a few problems with this issue: