Files
Go-http_framework/err/FileError.go
T

46 lines
624 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* @Author : huangzj
* @Time : 2020/4/26 15:09
* @Description
*/
package err
type FileError struct {
Err error
Mes string
}
func ENewFileError(err error) *FileError {
return &FileError{
Err: err,
Mes: "",
}
}
func NewFileError(mes string) *FileError {
return &FileError{
Err: nil,
Mes: mes,
}
}
func (e *FileError) Error() string {
if e == nil {
return "<nil>"
}
if e.Err != nil {
return e.Err.Error()
}
return e.Mes
}
/*
* 默认Error方法直接返回Err信息,所以这边只需要加一个方法返回Mes就可以
*/
func (e *FileError) ErrorMes() string {
return e.Mes
}