-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror.go
92 lines (76 loc) · 2.66 KB
/
error.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Copyright 2013 slowfei And The Contributors All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Create on 2013-9-10
// Update on 2014-07-02
// Email [email protected]
// Home http://www.slowfei.com
//
// error info manager
//
package leafveingo
import (
"fmt"
)
var (
// http session manager close status
ErrHttpSessionManagerClosed = NewLeafveinError("HttpSession manager has been closed or not started.")
ErrControllerReturnParam = NewLeafveinError("controllers return type parameter error.")
ErrControllerReturnParamNum = NewLeafveinError("controller returns the number of type parameters allowed only one.")
// 转发找不到控制器
ErrControllerDispatcherNotFound = NewLeafveinError("dispatcher: controller not found.")
ErrControllerDispatcherFuncNameNil = NewLeafveinError("dispatcher: func name is nil.")
// Leafvein app name repeat
ErrLeafveinAppNameRepeat = NewLeafveinError("Leafvein server app name repeat.")
// Leafveingo 配置对象未初始化
ErrLeafveinInitLoadConfig = NewLeafveinError("Leafvein initialized load config error.")
ErrLeafveinLoadDefaultConfig = NewLeafveinError("Leafvein load default config error.")
// host nil
ErrLeafveinSetHostNil = NewLeafveinError("Leafvein set host len()==0 or nil.")
// template path pase is nil
ErrTemplatePathParseNil = NewLeafveinError("template path parse is nil.")
// form params
ErrParampackParseFormParams = NewLeafveinError("form params parse error.")
ErrParampackNewStruct = NewLeafveinError("form params new struct error.")
)
// leafveingo error
type LeafveinError struct {
Message string
UserInfo string
}
// new error info
func NewLeafveinError(format string, args ...interface{}) *LeafveinError {
return &LeafveinError{fmt.Sprintf(format, args...), ""}
}
/**
* error string
*
* @return
*/
func (err *LeafveinError) Error() string {
errstr := "Message:(\"" + err.Message + "\");"
if 0 != len(err.UserInfo) {
errstr += " UserInfo:(\"" + err.UserInfo + "\")"
}
return errstr
}
/**
* equal error
*
* @param
* @return
*/
func (err *LeafveinError) Equal(eqErr *LeafveinError) bool {
return eqErr.Message == err.Message
}