File: error.go

package info (click to toggle)
golang-github-cznic-fileutil 0.0~git20150708.0.1c9c88f-4
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 392 kB
  • sloc: makefile: 21
file content (130 lines) | stat: -rw-r--r-- 2,670 bytes parent folder | download | duplicates (3)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// Copyright (c) 2011 CZ.NIC z.s.p.o. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// blame: jnml, labs.nic.cz

package falloc

import "fmt"

// EBadRequest is an error produced for invalid operation, e.g. for data of more than maximum allowed.
type EBadRequest struct {
	Name string
	Size int
}

func (e *EBadRequest) Error() string {
	return fmt.Sprintf("%s: size %d", e.Name, e.Size)
}

// EClose is a file/store close error.
type EClose struct {
	Name string
	Err  error
}

func (e *EClose) Error() string {
	return fmt.Sprintf("%sx: %s", e.Name, e.Err)
}

// ECorrupted is a file/store format error.
type ECorrupted struct {
	Name string
	Ofs  int64
}

func (e *ECorrupted) Error() string {
	return fmt.Sprintf("%s: corrupted data @%#x", e.Name, e.Ofs)
}

// ECreate is a file/store create error.
type ECreate struct {
	Name string
	Err  error
}

func (e *ECreate) Error() string {
	return fmt.Sprintf("%s: %s", e.Name, e.Err)
}

// EFreeList is a file/store format error.
type EFreeList struct {
	Name  string
	Size  int64
	Block int64
}

func (e *EFreeList) Error() string {
	return fmt.Sprintf("%s: invalid free list item, size %#x, block %#x", e.Name, e.Size, e.Block)
}

// EHandle is an error type reported for invalid Handles.
type EHandle struct {
	Name   string
	Handle Handle
}

func (e EHandle) Error() string {
	return fmt.Sprintf("%s: invalid handle %#x", e.Name, e.Handle)
}

// EHeader is a file/store format error.
type EHeader struct {
	Name     string
	Header   []byte
	Expected []byte
}

func (e *EHeader) Error() string {
	return fmt.Sprintf("%s: invalid header, got [% x], expected [% x]", e.Name, e.Header, e.Expected)
}

// ENullHandle is a file/store access error via a null handle.
type ENullHandle string

func (e ENullHandle) Error() string {
	return fmt.Sprintf("%s: access via null handle", e)
}

// EOpen is a file/store open error.
type EOpen struct {
	Name string
	Err  error
}

func (e *EOpen) Error() string {
	return fmt.Sprintf("%s: %s", e.Name, e.Err)
}

// ERead is a file/store read error.
type ERead struct {
	Name string
	Ofs  int64
	Err  error
}

func (e *ERead) Error() string {
	return fmt.Sprintf("%s, %#x: %s", e.Name, e.Ofs, e.Err)
}

// ESize is a file/store size error.
type ESize struct {
	Name string
	Size int64
}

func (e *ESize) Error() string {
	return fmt.Sprintf("%s: invalid size %#x(%d), size %%16 != 0", e.Name, e.Size, e.Size)
}

// EWrite is a file/store write error.
type EWrite struct {
	Name string
	Ofs  int64
	Err  error
}

func (e *EWrite) Error() string {
	return fmt.Sprintf("%s, %#x: %s", e.Name, e.Ofs, e.Err)
}