From 04025880ec3b9777f9f4929d75945e17fbe43c62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Espino?= Date: Thu, 28 Jul 2022 20:34:44 +0200 Subject: [PATCH] Showing panic trace on debug mode --- mage/template.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mage/template.go b/mage/template.go index 4f7125eb..848089a9 100644 --- a/mage/template.go +++ b/mage/template.go @@ -9,6 +9,8 @@ package main import ( "context" + _runtime_debug "runtime/debug" + _errors "errors" _flag "flag" _fmt "fmt" _ioutil "io/ioutil" @@ -279,7 +281,12 @@ Options: go func() { defer func() { err := recover() - d <- err + isDebug, _ := strconv.ParseBool(os.Getenv("MAGEFILE_DEBUG")) + if isDebug { + d <- _errors.New(string(_runtime_debug.Stack())) + } else { + d <- err + } }() err := fn(ctx) d <- err