forked from liushuochen/gotable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
file.go
69 lines (55 loc) · 1.63 KB
/
file.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
67
68
69
package exception
import "fmt"
type fileError struct {
*baseError
filename string
}
func createFileError(filename, message string) *fileError {
err := &fileError{baseError: createBaseError(message), filename: filename}
return err
}
func (err *fileError) Filename() string {
return err.filename
}
type FileDoNotExistError struct {
*fileError
}
func FileDoNotExist(path string) *FileDoNotExistError {
message := fmt.Sprintf("file %s do not exist", path)
err := &FileDoNotExistError{fileError: createFileError(path, message)}
return err
}
type NotARegularCSVFileError struct {
*fileError
}
func NotARegularCSVFile(path string) *NotARegularCSVFileError {
message := fmt.Sprintf("not a regular csv file: %s", path)
err := &NotARegularCSVFileError{fileError: createFileError(path, message)}
return err
}
type NotARegularJSONFileError struct {
*fileError
}
func NotARegularJSONFile(path string) *NotARegularJSONFileError {
message := fmt.Sprintf("not a regular json file: %s", path)
err := &NotARegularJSONFileError{fileError: createFileError(path, message)}
return err
}
type UnSupportedFileTypeError struct {
*fileError
}
func UnSupportedFileType(path string) *UnSupportedFileTypeError {
message := fmt.Sprintf("Unsupported file type %s", path)
err := &UnSupportedFileTypeError{
fileError: createFileError(path, message),
}
return err
}
type NotGotableJSONFormatError struct {
*fileError
}
func NotGotableJSONFormat(path string) *NotGotableJSONFormatError {
message := fmt.Sprintf("json file %s is not a valid gotable json format", path)
err := &NotGotableJSONFormatError{fileError: createFileError(path, message)}
return err
}