mirror of
https://github.com/1f349/go-webdav.git
synced 2024-12-22 08:14:15 +00:00
internal: use errors.As in IsNotFound
Allows it to work properly with wrapped errors.
This commit is contained in:
parent
9bc7a8f15b
commit
d0fc22a428
@ -2,6 +2,7 @@
|
|||||||
package internal
|
package internal
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
@ -84,7 +85,11 @@ func HTTPErrorFromError(err error) *HTTPError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func IsNotFound(err error) bool {
|
func IsNotFound(err error) bool {
|
||||||
return HTTPErrorFromError(err).Code == http.StatusNotFound
|
var httpErr *HTTPError
|
||||||
|
if errors.As(err, &httpErr) {
|
||||||
|
return httpErr.Code == http.StatusNotFound
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func HTTPErrorf(code int, format string, a ...interface{}) *HTTPError {
|
func HTTPErrorf(code int, format string, a ...interface{}) *HTTPError {
|
||||||
|
Loading…
Reference in New Issue
Block a user