feat: Start implementation of Afero-based filesystem abstraction
This commit is contained in:
22
internal/handlers/panic.go
Normal file
22
internal/handlers/panic.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"runtime/debug"
|
||||
)
|
||||
|
||||
func PanicHandler(h http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
http.Error(w, fmt.Sprintf("%v", r), http.StatusInternalServerError)
|
||||
|
||||
log.Println("Error:", r, "\nStack:", string(debug.Stack()))
|
||||
}
|
||||
}()
|
||||
|
||||
h.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user