diff --git a/tools/api.go b/tools/api.go index a9027f3..475c4d9 100644 --- a/tools/api.go +++ b/tools/api.go @@ -1,6 +1,8 @@ package tools import ( + "errors" + "cloud.o-forge.io/core/oc-lib/dbs/mongo" ) @@ -24,18 +26,22 @@ func (s State) String() string { type API struct{} -func (a *API) GetState() State { +func (a *API) GetState() (State, int, error) { // Check if the database is up err := mongo.MONGOService.TestDB(GetConfig()) if err != nil { - return DB_FALLOUT + return DB_FALLOUT, 200, err } err = mongo.MONGOService.TestCollections(GetConfig(), []string{}) if err != nil { - return UNPROCESSABLE_ENTITY + return UNPROCESSABLE_ENTITY, 200, err } if len(UncatchedError) > 0 { - return TEAPOT + errStr := "" + for _, e := range UncatchedError { + errStr += e.Error() + "\n" + } + return TEAPOT, 200, errors.New(errStr) } - return ALIVE + return ALIVE, 200, nil }