1
0
mirror of https://github.com/pocketbase/pocketbase.git synced 2024-11-21 13:35:49 +02:00

normalized internal errors formatting

This commit is contained in:
Gani Georgiev 2024-07-09 22:18:04 +03:00
parent 1f08b70283
commit 01450cde44
9 changed files with 12 additions and 12 deletions

View File

@ -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

View File

@ -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()

View File

@ -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 != "" {

View File

@ -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(
@ -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(
@ -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(
@ -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(

View File

@ -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")
}

View File

@ -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, ".")

View File

@ -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.

View File

@ -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 {

View File

@ -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 {