Simplify error handling in generator.
This commit is contained in:
parent
f5287628aa
commit
50bda95da2
10 changed files with 92 additions and 208 deletions
|
|
@ -25,31 +25,20 @@ type DBConnection struct {
|
|||
}
|
||||
|
||||
// Generate generates jet files at destination dir from database connection details
|
||||
func Generate(destDir string, dbConn DBConnection) error {
|
||||
func Generate(destDir string, dbConn DBConnection) (err error) {
|
||||
defer utils.ErrorCatch(&err)
|
||||
|
||||
db, err := openConnection(dbConn)
|
||||
utils.PanicOnError(err)
|
||||
defer utils.DBClose(db)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println("Retrieving schema information...")
|
||||
schemaInfo, err := metadata.GetSchemaMetaData(db, dbConn.SchemaName, &postgresQuerySet{})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
schemaInfo := metadata.GetSchemaMetaData(db, dbConn.SchemaName, &postgresQuerySet{})
|
||||
|
||||
genPath := path.Join(destDir, dbConn.DBName, dbConn.SchemaName)
|
||||
template.GenerateFiles(genPath, schemaInfo, postgres.Dialect)
|
||||
|
||||
err = template.GenerateFiles(genPath, schemaInfo, postgres.Dialect)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return
|
||||
}
|
||||
|
||||
func openConnection(dbConn DBConnection) (*sql.DB, error) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue