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:
parent
1f08b70283
commit
01450cde44
@ -111,7 +111,7 @@ func (api *fileApi) download(c echo.Context) error {
|
|||||||
|
|
||||||
options, ok := fileField.Options.(*schema.FileOptions)
|
options, ok := fileField.Options.(*schema.FileOptions)
|
||||||
if !ok {
|
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
|
// check whether the request is authorized to view the protected file
|
||||||
|
@ -371,7 +371,7 @@ type recordData struct {
|
|||||||
func (api *realtimeApi) broadcastRecord(action string, record *models.Record, dryCache bool) error {
|
func (api *realtimeApi) broadcastRecord(action string, record *models.Record, dryCache bool) error {
|
||||||
collection := record.Collection()
|
collection := record.Collection()
|
||||||
if collection == nil {
|
if collection == nil {
|
||||||
return errors.New("[broadcastRecord] Record collection not set.")
|
return errors.New("[broadcastRecord] Record collection not set")
|
||||||
}
|
}
|
||||||
|
|
||||||
clients := api.app.SubscriptionsBroker().Clients()
|
clients := api.app.SubscriptionsBroker().Clients()
|
||||||
|
@ -653,7 +653,7 @@ func (c AuthProviderConfig) Validate() error {
|
|||||||
// SetupProvider loads the current AuthProviderConfig into the specified provider.
|
// SetupProvider loads the current AuthProviderConfig into the specified provider.
|
||||||
func (c AuthProviderConfig) SetupProvider(provider auth.Provider) error {
|
func (c AuthProviderConfig) SetupProvider(provider auth.Provider) error {
|
||||||
if !c.Enabled {
|
if !c.Enabled {
|
||||||
return errors.New("The provider is not enabled.")
|
return errors.New("the provider is not enabled")
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.ClientId != "" {
|
if c.ClientId != "" {
|
||||||
|
@ -12,7 +12,7 @@ import (
|
|||||||
// NewRecordAuthToken generates and returns a new auth record authentication token.
|
// NewRecordAuthToken generates and returns a new auth record authentication token.
|
||||||
func NewRecordAuthToken(app core.App, record *models.Record) (string, error) {
|
func NewRecordAuthToken(app core.App, record *models.Record) (string, error) {
|
||||||
if !record.Collection().IsAuth() {
|
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(
|
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.
|
// NewRecordVerifyToken generates and returns a new record verification token.
|
||||||
func NewRecordVerifyToken(app core.App, record *models.Record) (string, error) {
|
func NewRecordVerifyToken(app core.App, record *models.Record) (string, error) {
|
||||||
if !record.Collection().IsAuth() {
|
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(
|
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.
|
// NewRecordResetPasswordToken generates and returns a new auth record password reset request token.
|
||||||
func NewRecordResetPasswordToken(app core.App, record *models.Record) (string, error) {
|
func NewRecordResetPasswordToken(app core.App, record *models.Record) (string, error) {
|
||||||
if !record.Collection().IsAuth() {
|
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(
|
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.
|
// NewRecordFileToken generates and returns a new record private file access token.
|
||||||
func NewRecordFileToken(app core.App, record *models.Record) (string, error) {
|
func NewRecordFileToken(app core.App, record *models.Record) (string, error) {
|
||||||
if !record.Collection().IsAuth() {
|
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(
|
return security.NewJWT(
|
||||||
|
@ -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")
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ func (r *SimpleFieldResolver) UpdateQuery(query *dbx.SelectQuery) error {
|
|||||||
// Returns error if `field` is not in `r.allowedFields`.
|
// Returns error if `field` is not in `r.allowedFields`.
|
||||||
func (r *SimpleFieldResolver) Resolve(field string) (*ResolverResult, error) {
|
func (r *SimpleFieldResolver) Resolve(field string) (*ResolverResult, error) {
|
||||||
if !list.ExistInSliceWithRegex(field, r.allowedFields) {
|
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, ".")
|
parts := strings.Split(field, ".")
|
||||||
|
@ -39,7 +39,7 @@ func ParseJWT(token string, verificationKey string) (jwt.MapClaims, error) {
|
|||||||
return claims, nil
|
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.
|
// NewJWT generates and returns new HS256 signed JWT.
|
||||||
|
@ -41,7 +41,7 @@ func (m *JsonArray[T]) Scan(value any) error {
|
|||||||
case string:
|
case string:
|
||||||
data = []byte(v)
|
data = []byte(v)
|
||||||
default:
|
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 {
|
if len(data) == 0 {
|
||||||
|
@ -56,7 +56,7 @@ func (m *JsonMap) Scan(value any) error {
|
|||||||
case string:
|
case string:
|
||||||
data = []byte(v)
|
data = []byte(v)
|
||||||
default:
|
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 {
|
if len(data) == 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user