From f0f6444daa0d78532ea522fc99ba4b58a3d2aa1b Mon Sep 17 00:00:00 2001 From: Lev Berman Date: Mon, 21 Sep 2015 13:26:39 +0300 Subject: [PATCH] Show a friendlier error message --- model_loader/model_loader.go | 2 +- model_loader/model_loader_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/model_loader/model_loader.go b/model_loader/model_loader.go index 1a608d6..ede11dc 100644 --- a/model_loader/model_loader.go +++ b/model_loader/model_loader.go @@ -170,7 +170,7 @@ func loadValue(key string, arg interface{}, field reflect.Value) error { func getFieldByName(model reflect.Value, name string) (reflect.Value, error) { field := model.Elem().FieldByName(name) if !field.IsValid() { - return reflect.ValueOf(nil), fmt.Errorf("Field `%s` does not exist.", name) + return reflect.ValueOf(nil), fmt.Errorf("Unknown option or argument: `%s`.", name) } return field, nil } diff --git a/model_loader/model_loader_test.go b/model_loader/model_loader_test.go index c261a40..7d13293 100644 --- a/model_loader/model_loader_test.go +++ b/model_loader/model_loader_test.go @@ -199,7 +199,7 @@ var testCases = []modelLoaderTestCase{ args: map[string]interface{}{ "UnknownField": "some value", }, - err: "Field `UnknownField` does not exist.", + err: "Unknown option or argument: `UnknownField`.", }, // Fails with different type mismatches. {