iris-contrib / middleware

Community Middleware List for the Iris Web Framework.

Home Page:https://github.com/kataras/iris

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why recovery not print panic err message by default ?

douglarek opened this issue · comments

Now Recovery just prints Recovery from panic;


 func (r recovery) Serve(ctx *iris.Context) {
         defer func() {
                 if err := recover(); err != nil {
                         r.out.Write([]byte("[IRIS:" + time.Now().String() + "] Recovery from panic \n"))
                         //ctx.Panic just sends  http status 500 by default, but you can change it by: iris.OnPanic(func( c *iris.Context){})
                         ctx.Panic()
                 }
         }()
         ctx.Next()
 }

Why not print panic err message by default here?

Hello @douglarek , I don't remember why I removed the message from there(maybe I was scared about dublication of the same error message from a previous panic catcher).

Fixed now, also instead of a io.Writer, you pass a Logger

package main

import (
    "github.com/kataras/iris"
    "github.com/iris-contrib/middleware/recovery"
)

func main() {
    iris.Use(recovery.New(iris.Logger))  // ....pass the station's logger
}