diff options
author | Colin Cross <ccross@android.com> | 2018-09-19 13:37:29 -0700 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2018-09-19 14:03:30 -0700 |
commit | 7f90d170b3c70a6f5b5aba873e524a0522f2cee9 (patch) | |
tree | 45e31325995414effa2d69e22ec1179c40f3a3b3 | |
parent | 0799fad550029be4109db6d81189edf20eb720c7 (diff) | |
download | android_build_blueprint-7f90d170b3c70a6f5b5aba873e524a0522f2cee9.tar.gz android_build_blueprint-7f90d170b3c70a6f5b5aba873e524a0522f2cee9.tar.bz2 android_build_blueprint-7f90d170b3c70a6f5b5aba873e524a0522f2cee9.zip |
Report panic context for SingletonContext.VisitAllModules
If a panic occurs in SingletonContext.VisitAllModules report the
module that was being visited.
Change-Id: Ia7fc07e2e33e9e3c0297903d3b06b7efb33f0105
-rw-r--r-- | singleton_ctx.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/singleton_ctx.go b/singleton_ctx.go index 333811d..1b044fa 100644 --- a/singleton_ctx.go +++ b/singleton_ctx.go @@ -212,7 +212,18 @@ func (s *singletonContext) AddSubninja(file string) { } func (s *singletonContext) VisitAllModules(visit func(Module)) { - s.context.VisitAllModules(visit) + var visitingModule Module + defer func() { + if r := recover(); r != nil { + panic(newPanicErrorf(r, "VisitAllModules(%s) for module %s", + funcName(visit), visitingModule)) + } + }() + + s.context.VisitAllModules(func(m Module) { + visitingModule = m + visit(m) + }) } func (s *singletonContext) VisitAllModulesIf(pred func(Module) bool, |