-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patherror.go
More file actions
42 lines (36 loc) · 1.48 KB
/
error.go
File metadata and controls
42 lines (36 loc) · 1.48 KB
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
// This file is subject to a 1-clause BSD license.
// Its contents can be found in the enclosed LICENSE file.
package spirv
import (
"errors"
"fmt"
)
var (
ErrUnexpectedEOF = errors.New("unexpected EOF")
ErrInvalidInstructionSize = errors.New("instruction has invalid size")
ErrMissingInstructionArgs = errors.New("insufficient instruction arguments")
ErrUnacceptable = errors.New("use of this instruction is not allowed")
ErrInstructionNotPointer = errors.New("value from Codec.New is not a pointer type")
ErrDuplicateInstruction = errors.New("duplicate opcode being registered")
ErrInvalidMagicValue = errors.New("Header: invalid magic value")
ErrInvalidVersion = errors.New("Header: invalid version number")
ErrMemoryModel = errors.New("a module must define one and only one OpMemoryModel")
ErrEntrypoint = errors.New("a module must define at least one OpEntrypoint")
ErrExecutionMode = errors.New("a module must define at least one OpExecutionMode")
)
// LayoutError defines an error in a module's structural layout.
type LayoutError struct {
Msg string
Address int
}
// NewLayoutError creates a new layout error for the given address and
// formatted message.
func NewLayoutError(addr int, msg string, argv ...interface{}) *LayoutError {
return &LayoutError{
Msg: fmt.Sprintf(msg, argv...),
Address: addr,
}
}
func (e *LayoutError) Error() string {
return fmt.Sprintf("at $%08x: %s", e.Address, e.Msg)
}