Skip to content

Commit

Permalink
normalized internal errors formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ganigeorgiev committed Jul 9, 2024
1 parent 1f08b70 commit 01450cd
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion apis/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (api *fileApi) download(c echo.Context) error {

options, ok := fileField.Options.(*schema.FileOptions)
if !ok {
return NewBadRequestError("", errors.New("Failed to load file options."))
return NewBadRequestError("", errors.New("failed to load file options"))
}

// check whether the request is authorized to view the protected file
Expand Down
2 changes: 1 addition & 1 deletion apis/realtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ type recordData struct {
func (api *realtimeApi) broadcastRecord(action string, record *models.Record, dryCache bool) error {
collection := record.Collection()
if collection == nil {
return errors.New("[broadcastRecord] Record collection not set.")
return errors.New("[broadcastRecord] Record collection not set")
}

clients := api.app.SubscriptionsBroker().Clients()
Expand Down
2 changes: 1 addition & 1 deletion models/settings/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ func (c AuthProviderConfig) Validate() error {
// SetupProvider loads the current AuthProviderConfig into the specified provider.
func (c AuthProviderConfig) SetupProvider(provider auth.Provider) error {
if !c.Enabled {
return errors.New("The provider is not enabled.")
return errors.New("the provider is not enabled")
}

if c.ClientId != "" {
Expand Down
8 changes: 4 additions & 4 deletions tokens/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
// NewRecordAuthToken generates and returns a new auth record authentication token.
func NewRecordAuthToken(app core.App, record *models.Record) (string, error) {
if !record.Collection().IsAuth() {
return "", errors.New("The record is not from an auth collection.")
return "", errors.New("the record is not from an auth collection")
}

return security.NewJWT(
Expand All @@ -29,7 +29,7 @@ func NewRecordAuthToken(app core.App, record *models.Record) (string, error) {
// NewRecordVerifyToken generates and returns a new record verification token.
func NewRecordVerifyToken(app core.App, record *models.Record) (string, error) {
if !record.Collection().IsAuth() {
return "", errors.New("The record is not from an auth collection.")
return "", errors.New("the record is not from an auth collection")
}

return security.NewJWT(
Expand All @@ -47,7 +47,7 @@ func NewRecordVerifyToken(app core.App, record *models.Record) (string, error) {
// NewRecordResetPasswordToken generates and returns a new auth record password reset request token.
func NewRecordResetPasswordToken(app core.App, record *models.Record) (string, error) {
if !record.Collection().IsAuth() {
return "", errors.New("The record is not from an auth collection.")
return "", errors.New("the record is not from an auth collection")
}

return security.NewJWT(
Expand Down Expand Up @@ -80,7 +80,7 @@ func NewRecordChangeEmailToken(app core.App, record *models.Record, newEmail str
// NewRecordFileToken generates and returns a new record private file access token.
func NewRecordFileToken(app core.App, record *models.Record) (string, error) {
if !record.Collection().IsAuth() {
return "", errors.New("The record is not from an auth collection.")
return "", errors.New("the record is not from an auth collection")
}

return security.NewJWT(
Expand Down
2 changes: 1 addition & 1 deletion tools/mailer/sendmail.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,5 @@ func findSendmailPath() (string, error) {
}
}

return "", errors.New("Failed to locate a sendmail executable path.")
return "", errors.New("failed to locate a sendmail executable path")
}
2 changes: 1 addition & 1 deletion tools/search/simple_field_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (r *SimpleFieldResolver) UpdateQuery(query *dbx.SelectQuery) error {
// Returns error if `field` is not in `r.allowedFields`.
func (r *SimpleFieldResolver) Resolve(field string) (*ResolverResult, error) {
if !list.ExistInSliceWithRegex(field, r.allowedFields) {
return nil, fmt.Errorf("Failed to resolve field %q.", field)
return nil, fmt.Errorf("failed to resolve field %q", field)
}

parts := strings.Split(field, ".")
Expand Down
2 changes: 1 addition & 1 deletion tools/security/jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func ParseJWT(token string, verificationKey string) (jwt.MapClaims, error) {
return claims, nil
}

return nil, errors.New("Unable to parse token.")
return nil, errors.New("unable to parse token")
}

// NewJWT generates and returns new HS256 signed JWT.
Expand Down
2 changes: 1 addition & 1 deletion tools/types/json_array.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (m *JsonArray[T]) Scan(value any) error {
case string:
data = []byte(v)
default:
return fmt.Errorf("Failed to unmarshal JsonArray value: %q.", value)
return fmt.Errorf("failed to unmarshal JsonArray value: %q", value)
}

if len(data) == 0 {
Expand Down
2 changes: 1 addition & 1 deletion tools/types/json_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (m *JsonMap) Scan(value any) error {
case string:
data = []byte(v)
default:
return fmt.Errorf("Failed to unmarshal JsonMap value: %q.", value)
return fmt.Errorf("failed to unmarshal JsonMap value: %q", value)
}

if len(data) == 0 {
Expand Down

0 comments on commit 01450cd

Please sign in to comment.