Skip to content

Commit

Permalink
rename error package
Browse files Browse the repository at this point in the history
  • Loading branch information
Nedim Akar committed Oct 31, 2023
1 parent b8cebbf commit f6c0744
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package errorz
package custom_error

import "errors"

Expand Down
6 changes: 3 additions & 3 deletions src/jetstream/datastore/datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"strings"
"time"

"github.com/cloudfoundry-incubator/stratos/src/jetstream/errorz"
"github.com/cloudfoundry-incubator/stratos/src/jetstream/custom_error"

goosedbversion "github.com/cloudfoundry-incubator/stratos/src/jetstream/repository/goose-db-version"
"github.com/govau/cf-common/env"
Expand Down Expand Up @@ -304,9 +304,9 @@ func WaitForMigrations(db *sql.DB) error {
databaseVersionRec, err := dbVersionRepo.GetCurrentVersion()
if err != nil {
var errorMsg = err.Error()
if strings.Contains(err.Error(), errorz.ERR_NO_SUCH_TABLE) {
if strings.Contains(err.Error(), custom_error.ERR_NO_SUCH_TABLE) {
errorMsg = "Waiting for versions table to be created"
} else if errors.Is(err, errorz.ErrNoDatabaseVersionsFound) {
} else if errors.Is(err, custom_error.ErrNoDatabaseVersionsFound) {
errorMsg = "Versions table is empty - waiting for migrations"
}
log.Infof("Database schema check: %s", errorMsg)
Expand Down
4 changes: 2 additions & 2 deletions src/jetstream/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"strings"
"time"

"github.com/cloudfoundry-incubator/stratos/src/jetstream/errorz"
"github.com/cloudfoundry-incubator/stratos/src/jetstream/custom_error"

"github.com/gorilla/context"
"github.com/govau/cf-common/env"
Expand Down Expand Up @@ -44,7 +44,7 @@ func handleSessionError(config api.PortalConfig, c echo.Context, err error, doNo

var netOpErr *net.OpError
if errors.As(err, &netOpErr) {
if netOpErr.Op == errorz.ERR_DIAL_TCP {
if netOpErr.Op == custom_error.ERR_DIAL_TCP {
return api.NewHTTPShadowError(
http.StatusServiceUnavailable,
"Service is currently unavailable",
Expand Down
4 changes: 2 additions & 2 deletions src/jetstream/plugins/kubernetes/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"errors"

"github.com/cloudfoundry-incubator/stratos/src/jetstream/api"
"github.com/cloudfoundry-incubator/stratos/src/jetstream/errorz"
"github.com/cloudfoundry-incubator/stratos/src/jetstream/custom_error"
"github.com/labstack/echo/v4"
log "github.com/sirupsen/logrus"

Expand Down Expand Up @@ -289,7 +289,7 @@ func (c *KubernetesSpecification) RequiresCert(ec echo.Context) error {
Message string
}
if err != nil {
if strings.Contains(err.Error(), errorz.ERR_X509_CERTIFICATE) {
if strings.Contains(err.Error(), custom_error.ERR_X509_CERTIFICATE) {
response.Status = http.StatusOK
response.Required = true
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
log "github.com/sirupsen/logrus"

"github.com/cloudfoundry-incubator/stratos/src/jetstream/api"
"github.com/cloudfoundry-incubator/stratos/src/jetstream/errorz"
"github.com/cloudfoundry-incubator/stratos/src/jetstream/custom_error"
)

const (
Expand Down Expand Up @@ -37,7 +37,7 @@ func (p *PostgresGooseDBVersionRepository) GetCurrentVersion() (api.GooseDBVersi

switch {
case err == sql.ErrNoRows:
return api.GooseDBVersionRecord{}, errorz.ErrNoDatabaseVersionsFound
return api.GooseDBVersionRecord{}, custom_error.ErrNoDatabaseVersionsFound
case err != nil:
return api.GooseDBVersionRecord{}, fmt.Errorf("Error trying to get current database version: %v", err)
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
. "github.com/smartystreets/goconvey/convey"

"github.com/cloudfoundry-incubator/stratos/src/jetstream/api"
"github.com/cloudfoundry-incubator/stratos/src/jetstream/errorz"
"github.com/cloudfoundry-incubator/stratos/src/jetstream/custom_error"
)

func TestPgSQLGooseDB(t *testing.T) {
Expand Down Expand Up @@ -72,7 +72,7 @@ func TestPgSQLGooseDB(t *testing.T) {
Convey("there should be an error", func() {
repository, _ := NewPostgresGooseDBVersionRepository(db)
_, err := repository.GetCurrentVersion()
So(err, ShouldResemble, errorz.ErrNoDatabaseVersionsFound)
So(err, ShouldResemble, custom_error.ErrNoDatabaseVersionsFound)

dberr := mock.ExpectationsWereMet()
So(dberr, ShouldBeNil)
Expand Down
4 changes: 2 additions & 2 deletions src/jetstream/setup_console.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/cloudfoundry-incubator/stratos/src/jetstream/api"
"github.com/cloudfoundry-incubator/stratos/src/jetstream/api/config"
"github.com/cloudfoundry-incubator/stratos/src/jetstream/crypto"
"github.com/cloudfoundry-incubator/stratos/src/jetstream/errorz"
"github.com/cloudfoundry-incubator/stratos/src/jetstream/custom_error"
"github.com/cloudfoundry-incubator/stratos/src/jetstream/repository/console_config"
"github.com/cloudfoundry-incubator/stratos/src/jetstream/repository/localusers"
)
Expand Down Expand Up @@ -94,7 +94,7 @@ func (p *portalProxy) setupGetAvailableScopes(c echo.Context) error {
errInfo, ok := err.(api.ErrHTTPRequest)
if ok {
if errInfo.Status == 0 {
if strings.Contains(errInfo.Error(), errorz.ERR_X509_CERTIFICATE) {
if strings.Contains(errInfo.Error(), custom_error.ERR_X509_CERTIFICATE) {
return api.NewHTTPShadowError(
http.StatusBadRequest,
"Could not connect to the UAA - Certificate error - check Skip SSL validation setting",
Expand Down

0 comments on commit f6c0744

Please sign in to comment.