-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patherrrequestcancelled.go
More file actions
43 lines (35 loc) · 941 Bytes
/
errrequestcancelled.go
File metadata and controls
43 lines (35 loc) · 941 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package jaws
import (
"fmt"
"github.com/linkdata/jaws/lib/assets"
)
// ErrRequestCancelled indicates a Request was cancelled. Use Unwrap() to see the underlying cause.
var ErrRequestCancelled errRequestCancelled
type errRequestCancelled struct {
JawsKey uint64
Cause error
Initial string
}
func (e errRequestCancelled) Error() string {
return fmt.Sprintf("Request<%s>:%s %v", assets.JawsKeyString(e.JawsKey), e.Initial, e.Cause)
}
func (e errRequestCancelled) Is(target error) (yes bool) {
return target == ErrRequestCancelled
}
func (e errRequestCancelled) Unwrap() error {
return e.Cause
}
func newErrRequestCancelledLocked(rq *Request, cause error) (err error) {
if cause != nil {
var initial string
if rq.initial != nil {
initial = fmt.Sprintf(" %s %q:", rq.initial.Method, rq.initial.RequestURI)
}
err = errRequestCancelled{
JawsKey: rq.JawsKey,
Cause: cause,
Initial: initial,
}
}
return
}