1 Star 0 Fork 0

iqingfeng/ngrok

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
errors.go 676 Bytes
一键复制 编辑 原始数据 按行查看 历史
package util
import (
"fmt"
"runtime"
)
const crashMessage = `panic: %v
%s
Oh noes! ngrok crashed!
Please submit the stack trace and any relevant information to:
github.com/inconshreveable/ngrok/issues`
func MakePanicTrace(err interface{}) string {
stackBuf := make([]byte, 4096)
n := runtime.Stack(stackBuf, false)
return fmt.Sprintf(crashMessage, err, stackBuf[:n])
}
// Runs the given function and converts any panic encountered while doing so
// into an error. Useful for sending to channels that will close
func PanicToError(fn func()) (err error) {
defer func() {
if r := recover(); r != nil {
err = fmt.Errorf("Panic: %v", r)
}
}()
fn()
return
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/iqingfeng/ngrok.git
git@gitee.com:iqingfeng/ngrok.git
iqingfeng
ngrok
ngrok
e5a7b820743f

搜索帮助