-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathreadererror.go
52 lines (47 loc) · 1.2 KB
/
readererror.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
// Copyright 2015-2018, Shulhan <[email protected]>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package dsv
import (
"fmt"
)
const (
_ = iota
// EReadMissLeftQuote read error when no left-quote found on line.
EReadMissLeftQuote
// EReadMissRightQuote read error when no right-quote found on line.
EReadMissRightQuote
// EReadMissSeparator read error when no separator found on line.
EReadMissSeparator
// EReadLine error when reading line from file.
EReadLine
// EReadEOF error which indicated end-of-file.
EReadEOF
// ETypeConversion error when converting type from string to numeric or
// vice versa.
ETypeConversion
)
//
// ReaderError to handle error data and message.
//
type ReaderError struct {
// T define type of error.
T int
// Func where error happened
Func string
// What cause the error?
What string
// Line define the line which cause error
Line string
// Pos character position which cause error
Pos int
// N line number
N int
}
//
// Error to string.
//
func (e *ReaderError) Error() string {
return fmt.Sprintf("dsv.Reader.%-20s [%d:%d]: %-30s data:|%s|", e.Func, e.N,
e.Pos, e.What, e.Line)
}