Improve error reporting
Report module name and variant and property names in errors.
Change-Id: I747f840402497b2c92bf8c565d7c50af33e6ab0e
diff --git a/module_ctx.go b/module_ctx.go
index 88bb7eb..22896c2 100644
--- a/module_ctx.go
+++ b/module_ctx.go
@@ -193,7 +193,7 @@
func (d *baseModuleContext) Errorf(pos scanner.Position,
format string, args ...interface{}) {
- d.error(&Error{
+ d.error(&BlueprintError{
Err: fmt.Errorf(format, args...),
Pos: pos,
})
@@ -202,9 +202,12 @@
func (d *baseModuleContext) ModuleErrorf(format string,
args ...interface{}) {
- d.error(&Error{
- Err: fmt.Errorf(format, args...),
- Pos: d.module.pos,
+ d.error(&ModuleError{
+ BlueprintError: BlueprintError{
+ Err: fmt.Errorf(format, args...),
+ Pos: d.module.pos,
+ },
+ module: d.module,
})
}
@@ -217,11 +220,15 @@
pos = d.module.pos
}
- format = property + ": " + format
-
- d.error(&Error{
- Err: fmt.Errorf(format, args...),
- Pos: pos,
+ d.error(&PropertyError{
+ ModuleError: ModuleError{
+ BlueprintError: BlueprintError{
+ Err: fmt.Errorf(format, args...),
+ Pos: pos,
+ },
+ module: d.module,
+ },
+ property: property,
})
}
@@ -248,9 +255,12 @@
args ...interface{}) {
module := m.context.moduleInfo[logicModule]
- m.errs = append(m.errs, &Error{
- Err: fmt.Errorf(format, args...),
- Pos: module.pos,
+ m.errs = append(m.errs, &ModuleError{
+ BlueprintError: BlueprintError{
+ Err: fmt.Errorf(format, args...),
+ Pos: module.pos,
+ },
+ module: module,
})
}