Code formatting and cleanup (#442)

* Formatting, extract error messages
* More refactor
* Move errors to a separate file
* Add missing file
* Misc
This commit is contained in:
Dan Sosedoff
2019-09-29 12:16:42 -05:00
committed by GitHub
parent c4db1973c4
commit 7a6450091a
6 changed files with 109 additions and 66 deletions

View File

@@ -54,7 +54,7 @@ func (be Backend) FetchCredential(resource string, c *gin.Context) (*BackendCred
log.Println("Unable to fetch backend credential:", err)
// We dont want to expose the url of the backend here, so reply with generic error
return nil, fmt.Errorf("Unable to connect to the auth backend")
return nil, errBackendConnectError
}
defer resp.Body.Close()
@@ -67,7 +67,7 @@ func (be Backend) FetchCredential(resource string, c *gin.Context) (*BackendCred
return nil, err
}
if cred.DatabaseURL == "" {
return nil, fmt.Errorf("Database URL was not provided")
return nil, errConnStringRequired
}
return cred, nil