Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Latest commit c664a51 Apr 17, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
catchers log now writes to standard error Apr 14, 2019
.gitignore initial commit Apr 12, 2019
LICENSE Create LICENSE Apr 17, 2019
go.mod fixed travis Apr 13, 2019
go.sum fixed travis Apr 13, 2019
panicMiddleware.go log now writes to standard error Apr 14, 2019
panicMiddleware_test.go ensure a 500 given an error Apr 13, 2019



GoDoc Build Status

go-panic-catch is a simple middleware for golang web servers that recovers from panics and enables you to handle panics gracefully.

To get it:

go get

And then to use it:

package main

import (

func main() {
	fn := func(writer http.ResponseWriter, req *http.Request) {
		panic("ut oh")

	//something that satisfies panicHandler interface
	slack := catchers.NewSlack("some-webhook-url")

	server := &http.Server{
		Handler: goCatch.PanicMiddleware(*slack, "recovering from panic will write this to slack", http.HandlerFunc(fn)),


It should also work with all the popular web servers such as gorillia mux and gin.

go-panic-catch currently comes with two "catchers" that handle panics.

  • slack catcher - will write a message to slack everytime your web server panics
  • log - Logs "message" every time there is a panic.

Want to implement your own handler? Simply implement the following interface:

type PanicHandler interface {
	HandlePanic(message string) error

Some ideas for other handlers:

  • email everytime there is a panic.
  • increment a prometheus counter.

(contributions appreciated if you want to work on these)

You can’t perform that action at this time.