/
githubmirror
/
GoFrame
Обзор
Документация
Войти
/
githubmirror
/
GoFrame
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
errors/gerror/gerror_api_option.go
31 строка
945 B
John Guo
improve package gerror, add HasCode/HasError function for package gerror (#2006)
15 июл 2022, 05:49
Не верифицирован
15 июл 2022, 05:49
5d51e9f
Код
Авторство
О чём код?
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. // // This Source Code Form is subject to the terms of the MIT License. // If a copy of the MIT was not distributed with this file, // You can obtain one at https://github.com/gogf/gf. package gerror import "github.com/gogf/gf/v2/errors/gcode" // Option is option for creating error. type Option struct { Error error // Wrapped error if any. Stack bool // Whether recording stack information into error. Text string // Error text, which is created by New* functions. Code gcode.Code // Error code if necessary. } // NewOption creates and returns a custom error with Option. // It is the senior usage for creating error, which is often used internally in framework. func NewOption(option Option) error { err := &Error{ error: option.Error, text: option.Text, code: option.Code, } if option.Stack { err.stack = callers() } return err }