Skip to content

Commit

Permalink
Simplify context error (#1431)
Browse files Browse the repository at this point in the history
Hello!

Looking through context package and found a little bit complicated switch block. And tried to make it easier.

Thanks!
  • Loading branch information
dmirogin authored and appleboy committed Aug 5, 2018
1 parent 220e8d3 commit 631cfbd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,15 @@ func (c *Context) Error(err error) *Error {
if err == nil {
panic("err is nil")
}
var parsedError *Error
switch err.(type) {
case *Error:
parsedError = err.(*Error)
default:

parsedError, ok := err.(*Error)
if !ok {
parsedError = &Error{
Err: err,
Type: ErrorTypePrivate,
}
}

c.Errors = append(c.Errors, parsedError)
return parsedError
}
Expand Down
2 changes: 1 addition & 1 deletion ginS/gins.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
// It is a shortcut for http.ListenAndServeTLS(addr, certFile, keyFile, router)
// 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)
}

Expand Down

0 comments on commit 631cfbd

Please sign in to comment.