exception - Andals/gobox GitHub Wiki

简介

我们通常在处理错误时,会使用errno和errmsg来标示一个错误,这个包就是对这类错误的封装。

因为golang自身并没有异常机制,模拟改机制需要用到panic,我们认为异常和panic在设计上不应当混用,所以这里的exception对象也只是封装了errno和errmsg。

用法

import

import (
    "andals/gobox/exception"
)

exception结构

type Exception struct {
	errno int
	msg   string
}

func (this *Exception) Error() string //实现error接口
func (this *Exception) Errno() int
func (this *Exception) Msg() string