gitee.com/quant1x/gox@v1.7.6/exception/errors.go (about)

     1  package exception
     2  
     3  import (
     4  	"fmt"
     5  )
     6  
     7  type Throwable interface {
     8  	error
     9  	Code() int
    10  }
    11  
    12  type Exception struct {
    13  	Throwable
    14  	code    int
    15  	message string
    16  }
    17  
    18  func New(code int, message string) *Exception {
    19  	return &Exception{
    20  		code:    code,
    21  		message: message,
    22  	}
    23  }
    24  
    25  func (this Exception) Error() string {
    26  	return fmt.Sprintf("#%d, message=%s", this.code, this.message)
    27  }
    28  
    29  func (this Exception) Code() int {
    30  	return this.code
    31  }
    32  
    33  // PanicIgnore 忽略panic, 继续执行
    34  func PanicIgnore() {
    35  	// 解析失败以后输出日志, 以备检查
    36  	if err := recover(); err != nil {
    37  		//logger.Errorf("panic ignore, error=%+v\n", err)
    38  	}
    39  }