This repository has been archived by the owner on Aug 15, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.go
66 lines (52 loc) · 1.77 KB
/
errors.go
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright 2016 Tom Thorogood. All rights reserved.
// Use of this source code is governed by a
// Modified BSD License license that can be found in
// the LICENSE file.
package blocker
import "errors"
var (
// ErrClosed will be returned on attempts to call
// methods on a closed server or client.
ErrClosed = errors.New("shared memory closed")
// ErrAlreadyBatching will be returned on attempts to call
// (*Server).Batch() when the *Server is already
// batching.
ErrAlreadyBatching = errors.New("already batching")
// ErrNotBatching will be returned on attempts to call
// (*Server).Commit() when (*Server).Batch() has
// not previously been called.
ErrNotBatching = errors.New("not batching")
// ErrInvalidSharedMemory will be returned in most Client
// functions if the backing shared memory is invalid at
// the time of the call.
ErrInvalidSharedMemory = errors.New("invalid shared memory")
errRangeTooLarge = errors.New("range too large")
errInvalidHeader = errors.New("invalid header")
)
// InvalidDataError will be returned by (*Server).Load() if the reader
// contains invalid data.
type InvalidDataError struct {
Err error
}
func (e InvalidDataError) Error() string {
if e.Err == nil {
return "invalid data"
}
return "invalid data: " + e.Err.Error()
}
// LockReleaseFailedError records that a lock could not
// be released and any error that was occuring.
//
// LockReleaseFailedError are serious errors and may mean
// that shared memory is in an invalid state and no further
// writes to shared memory by the server process will be
// possible.
type LockReleaseFailedError struct {
Err error
}
func (e LockReleaseFailedError) Error() string {
if e.Err == nil {
return "failed to release read lock"
}
return "failed to release read lock: " + e.Err.Error()
}