Better error reporting on /v2/bearings
package core
import (
+ "fmt"
+
"github.com/starkandwayne/shield/db"
)
@@ -28,7 +30,7 @@ func (c *Core) BearingFor(m *db.Membership) (Bearing, error) {
b.Tenant, err = c.db.GetTenant(m.TenantUUID)
if err != nil {
- return b, err
+ return b, fmt.Errorf("unable to retrieve tenant [%s]: ", m.TenantUUID, err)
}
b.Role = m.Role
switch b.Role {
@@ -44,31 +46,31 @@ func (c *Core) BearingFor(m *db.Membership) (Bearing, error) {
b.Archives, err = c.db.GetAllArchives(&db.ArchiveFilter{ForTenant: b.Tenant.UUID})
if err != nil {
- return b, err
+ return b, fmt.Errorf("unable to retreieve archives for tenant [%s]: %s", b.Tenant.UUID, err)
}
/* assemble jobs for this tenant */
b.Jobs, err = c.db.GetAllJobs(&db.JobFilter{ForTenant: b.Tenant.UUID})
if err != nil {
- return b, err
+ return b, fmt.Errorf("unable to retreive jobs for tenant [%s]: %s", b.Tenant.UUID, err)
}
/* assemble targets for this tenant */
b.Targets, err = c.db.GetAllTargets(&db.TargetFilter{ForTenant: b.Tenant.UUID})
if err != nil {
- return b, err
+ return b, fmt.Errorf("unable to retrieve targets for tenant [%s]: %s", b.Tenant.UUID, err)
}
/* assemble stores for this tenant */
b.Stores, err = c.db.GetAllStores(&db.StoreFilter{ForTenant: b.Tenant.UUID})
if err != nil {
- return b, err
+ return b, fmt.Errorf("unable to retrieve stores for tenant [%s]: %s", b.Tenant.UUID, err)
}
/* assemble agents and plugins for this tenant */
b.Agents, err = c.db.GetAllAgents(&db.AgentFilter{SkipHidden: true, InflateMetadata: true})
if err != nil {
- return b, err
+ return b, fmt.Errorf("unable to retrieve agents for tenant [%s]: %s", b.Tenant.UUID, err)
}
return b, nil
