forked from mirror/gin
Simplify context error (#1431)
Hello! Looking through context package and found a little bit complicated switch block. And tried to make it easier. Thanks!
This commit is contained in:
parent
220e8d3453
commit
631cfbd1ef
|
@ -159,16 +159,15 @@ func (c *Context) Error(err error) *Error {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
panic("err is nil")
|
panic("err is nil")
|
||||||
}
|
}
|
||||||
var parsedError *Error
|
|
||||||
switch err.(type) {
|
parsedError, ok := err.(*Error)
|
||||||
case *Error:
|
if !ok {
|
||||||
parsedError = err.(*Error)
|
|
||||||
default:
|
|
||||||
parsedError = &Error{
|
parsedError = &Error{
|
||||||
Err: err,
|
Err: err,
|
||||||
Type: ErrorTypePrivate,
|
Type: ErrorTypePrivate,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
c.Errors = append(c.Errors, parsedError)
|
c.Errors = append(c.Errors, parsedError)
|
||||||
return parsedError
|
return parsedError
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,7 @@ func Run(addr ...string) (err error) {
|
||||||
// RunTLS : The router is attached to a http.Server and starts listening and serving HTTPS requests.
|
// RunTLS : The router is attached to a http.Server and starts listening and serving HTTPS requests.
|
||||||
// It is a shortcut for http.ListenAndServeTLS(addr, certFile, keyFile, router)
|
// It is a shortcut for http.ListenAndServeTLS(addr, certFile, keyFile, router)
|
||||||
// Note: this method will block the calling goroutine undefinitelly unless an error happens.
|
// Note: this method will block the calling goroutine undefinitelly unless an error happens.
|
||||||
func RunTLS(addr string, certFile string, keyFile string) (err error) {
|
func RunTLS(addr, certFile, keyFile string) (err error) {
|
||||||
return engine().RunTLS(addr, certFile, keyFile)
|
return engine().RunTLS(addr, certFile, keyFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue