Improve error message for custom capture
sievlev opened this issue · 2 comments
sievlev commented
If custom capture generate an error, then user will receive an error message with full struct name.
diff --git a/_examples/ini/main.go b/_examples/ini/main.go
index be6ec9e..e483923 100644
--- a/_examples/ini/main.go
+++ b/_examples/ini/main.go
@@ -1,6 +1,7 @@
package main
import (
+ "errors"
"os"
"github.com/alecthomas/repr"
@@ -51,11 +52,17 @@ type String struct {
func (String) value() {}
type Number struct {
- Number float64 `@Float`
+ Number N `@Float`
}
func (Number) value() {}
+type N struct{}
+
+func (*N) Capture(values []string) error {
+ return errors.New("problem")
+}
+
panic: Number.Number: problem
An error message with type name or token name will be much better:
<float>: problem
alecthomas commented
Mmm yeah, that's not ideal and doesn't match the rest of the error reporting.