diff --git a/internal/module/module.go b/internal/module/module.go index 4a82f59..730c84f 100644 --- a/internal/module/module.go +++ b/internal/module/module.go @@ -10,9 +10,9 @@ import ( ) type ModuleError struct { - Index int - Config config.ModuleConfig - Error error + Index int `json:"index"` + Config config.ModuleConfig `json:"config"` + Error string `json:"error"` } type Module interface { diff --git a/internal/route/route.go b/internal/route/route.go index 351448d..cf6be43 100644 --- a/internal/route/route.go +++ b/internal/route/route.go @@ -13,9 +13,9 @@ import ( ) type RouteError struct { - Index int - Config config.RouteConfig - Error error + Index int `json:"index"` + Config config.RouteConfig `json:"config"` + Error string `json:"error"` } type Route struct { input string diff --git a/router.go b/router.go index a12e19e..a7e247c 100644 --- a/router.go +++ b/router.go @@ -131,7 +131,7 @@ func NewRouter(config config.Config) (*Router, []module.ModuleError, []route.Rou moduleErrors = append(moduleErrors, module.ModuleError{ Index: moduleIndex, Config: moduleDecl, - Error: err, + Error: err.Error(), }) continue } @@ -148,7 +148,7 @@ func NewRouter(config config.Config) (*Router, []module.ModuleError, []route.Rou routeErrors = append(routeErrors, route.RouteError{ Index: routeIndex, Config: routeDecl, - Error: err, + Error: err.Error(), }) continue } diff --git a/router_test.go b/router_test.go index 441e03c..2359245 100644 --- a/router_test.go +++ b/router_test.go @@ -149,8 +149,8 @@ func TestNewRouterDuplicateModuleId(t *testing.T) { t.Fatalf("router should have returned exactly 1 module error, got: %d", len(moduleErrors)) } - if moduleErrors[0].Error.Error() != "module id already exists" { - t.Fatalf("module error did not match expected, got: %s", moduleErrors[0].Error.Error()) + if moduleErrors[0].Error != "module id already exists" { + t.Fatalf("module error did not match expected, got: %s", moduleErrors[0].Error) } } @@ -184,8 +184,8 @@ func TestNewRouterRouteWithUnknwonProcessor(t *testing.T) { t.Fatalf("router should have returned exactly 1 route error, got: %d", len(routeErrors)) } - if routeErrors[0].Error.Error() != "problem loading processor registration for processor type: asdfasdf" { - t.Fatalf("route error did not match expected, got: %s", routeErrors[0].Error.Error()) + if routeErrors[0].Error != "problem loading processor registration for processor type: asdfasdf" { + t.Fatalf("route error did not match expected, got: %s", routeErrors[0].Error) } }