Skip to content

Commit

Permalink
Report error on load extension
Browse files Browse the repository at this point in the history
Closes issue #181
  • Loading branch information
nati committed Apr 26, 2016
1 parent 6a58d02 commit 4e101ab
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 33 deletions.
20 changes: 10 additions & 10 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,23 +178,23 @@ It's especially useful to validate schema files against gohan meta-schema.`,
Action: func(c *cli.Context) {
schemaPath := c.String("schema")
documentPaths := c.StringSlice("document")
if len(documentPaths) == 0 {
util.ExitFatalf("At least one document should be specified for validation\n")
}
if len(documentPaths) == 0 {
util.ExitFatalf("At least one document should be specified for validation\n")
}

manager := schema.GetManager()
err := manager.LoadSchemaFromFile(schemaPath)
if err != nil {
util.ExitFatal("Failed to parse schema:", err)
}

for _, documentPath := range documentPaths {
err = manager.LoadSchemaFromFile(documentPath)
if err != nil {
util.ExitFatalf("Schema is not valid, see errors below:\n%s\n", err)
}
}
fmt.Println("Schema is valid")
for _, documentPath := range documentPaths {
err = manager.LoadSchemaFromFile(documentPath)
if err != nil {
util.ExitFatalf("Schema is not valid, see errors below:\n%s\n", err)
}
}
fmt.Println("Schema is valid")
},
}
}
Expand Down
5 changes: 4 additions & 1 deletion extension/multienv.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ func (env *MultiEnvironment) SetUp() {
//LoadExtensionsForPath for returns extensions for specific path
func (env *MultiEnvironment) LoadExtensionsForPath(extensions []*schema.Extension, path string) error {
for _, env := range env.childEnv {
env.LoadExtensionsForPath(extensions, path)
err := env.LoadExtensionsForPath(extensions, path)
if err != nil {
return err
}
}
return nil
}
Expand Down
44 changes: 22 additions & 22 deletions util/go-bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4e101ab

Please sign in to comment.