Midtrans / midtrans-go

This is the Official Go API client/library for Midtrans Payment API. More information about the product and see documentation at http://docs.midtrans.com for more technical details
https://pkg.go.dev/github.com/midtrans/midtrans-go
MIT License
93 stars 25 forks source link

midtrans.Error doesn't implement Error interface #9

Closed yursan9 closed 2 years ago

yursan9 commented 2 years ago

Can you guys add Error method to midtrans.Error so it's compatible with standard errors package?

Xaxxis commented 2 years ago

@yursan9 thank you for reaching out to us. Could you help to elaborate more details or give us a simple sample code? So we can get more details about your concern. Thank you

yursan9 commented 2 years ago

I usually wrap 3rd party call on our own function, I want to be able to wrap and persist midtrans.Error if I bubble up the error

func SnapRequest(...) error {
    req := &snap.Request{...}
    resp, err := snapClient.CreateTransaction(req)
    if err != nil {
        return fmt.Errorf("Error on calling Create Transaction: %w.", err)
    }
    return nil
}

I want to be able using errors.Is and errors.As to checks if error is on calling midtrans API or on other process. What I want is for you to make midtrans.Error implement modern error value; https://go.dev/blog/go1.13-errors

Xaxxis commented 2 years ago

Hi, @yursan9 this seems like enhancement/changes that need to be further checked & tested to ensure proper compatibility, also to avoid breaking changes. Will take a look at this. But unfortunately, we still don't have any ETA yet. Otherwise, if you have already tried on your side and have the changes. Feel free to submit a pull request.

Thank you

yursan9 commented 2 years ago

I guess I'll try to submit the PR later

Xaxxis commented 2 years ago

Hi, @yursan9 this request is already on the new version, if you have any questions please create a new one. Thank you