publisher: replacing error assertions with errors.As (#5147)
Part of #5010
This commit is contained in:
parent
176253addd
commit
cd3a06b76c
|
@ -10,6 +10,7 @@ import (
|
||||||
"encoding/asn1"
|
"encoding/asn1"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -254,8 +255,9 @@ func (pub *Impl) SubmitToSingleCTWithResult(ctx context.Context, req *pubpb.Requ
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var body string
|
var body string
|
||||||
if respErr, ok := err.(jsonclient.RspError); ok && respErr.StatusCode < 500 {
|
var rspErr jsonclient.RspError
|
||||||
body = string(respErr.Body)
|
if errors.As(err, &rspErr) && rspErr.StatusCode < 500 {
|
||||||
|
body = string(rspErr.Body)
|
||||||
}
|
}
|
||||||
pub.log.AuditErrf("Failed to submit certificate to CT log at %s: %s Body=%q",
|
pub.log.AuditErrf("Failed to submit certificate to CT log at %s: %s Body=%q",
|
||||||
ctLog.uri, err, body)
|
ctLog.uri, err, body)
|
||||||
|
@ -291,7 +293,8 @@ func (pub *Impl) singleLogSubmit(
|
||||||
status = "canceled"
|
status = "canceled"
|
||||||
}
|
}
|
||||||
httpStatus := ""
|
httpStatus := ""
|
||||||
if rspError, ok := err.(ctClient.RspError); ok && rspError.StatusCode != 0 {
|
var rspError ctClient.RspError
|
||||||
|
if errors.As(err, &rspError) && rspError.StatusCode != 0 {
|
||||||
httpStatus = fmt.Sprintf("%d", rspError.StatusCode)
|
httpStatus = fmt.Sprintf("%d", rspError.StatusCode)
|
||||||
}
|
}
|
||||||
pub.metrics.submissionLatency.With(prometheus.Labels{
|
pub.metrics.submissionLatency.With(prometheus.Labels{
|
||||||
|
|
Loading…
Reference in New Issue