mirror of
https://github.com/mattermost/mattermost.git
synced 2026-09-24 16:05:00 +08:00
manage error the same way property field and value do
This commit is contained in:
+4
-12
@@ -5034,10 +5034,6 @@
|
||||
"id": "app.custom_profile_attributes.get_property_field.app_error",
|
||||
"translation": "Unable to get Custom Profile Attribute field"
|
||||
},
|
||||
{
|
||||
"id": "app.custom_profile_attributes.invalid_options.app_error",
|
||||
"translation": "Unable to validate the options"
|
||||
},
|
||||
{
|
||||
"id": "app.custom_profile_attributes.limit_reached.app_error",
|
||||
"translation": "Custom Profile Attributes field limit reached"
|
||||
@@ -5066,18 +5062,14 @@
|
||||
"id": "app.custom_profile_attributes.property_value_upsert.app_error",
|
||||
"translation": "Unable to upsert Custom Profile Attribute fields"
|
||||
},
|
||||
{
|
||||
"id": "app.custom_profile_attributes.sanitize_and_validate.app_error",
|
||||
"translation": "Invalid property value attributes : {{.AttributeName}} ({{.Reason}})."
|
||||
},
|
||||
{
|
||||
"id": "app.custom_profile_attributes.search_property_fields.app_error",
|
||||
"translation": "Unable to search Custom Profile Attribute fields"
|
||||
},
|
||||
{
|
||||
"id": "app.custom_profile_attributes.unknown_value_type.app_error",
|
||||
"translation": "The value type '{{.ValueType}}' is not supported"
|
||||
},
|
||||
{
|
||||
"id": "app.custom_profile_attributes.unknown_visibility.app_error",
|
||||
"translation": "The visibility '{{.Visibility}}' is not supported"
|
||||
},
|
||||
{
|
||||
"id": "app.delete_scheduled_post.delete_error",
|
||||
"translation": "Failed to delete scheduled post from database."
|
||||
|
||||
@@ -136,7 +136,10 @@ func (c *CPAField) SanitizeAndValidate() *AppError {
|
||||
case PropertyFieldTypeText:
|
||||
if valueType := strings.TrimSpace(c.Attrs.ValueType); valueType != "" {
|
||||
if !IsKnownCPAValueType(valueType) {
|
||||
return NewAppError("ValidateCPAField", "app.custom_profile_attributes.unknown_value_type.app_error", map[string]any{"ValueType": valueType}, "", http.StatusUnprocessableEntity)
|
||||
return NewAppError("SanitizeAndValidate", "app.custom_profile_attributes.sanitize_and_validate.app_error", map[string]any{
|
||||
"AttributeName": CustomProfileAttributesPropertyAttrsValueType,
|
||||
"Reason": "unknown value type",
|
||||
}, "", http.StatusUnprocessableEntity)
|
||||
}
|
||||
c.Attrs.ValueType = valueType
|
||||
}
|
||||
@@ -152,7 +155,10 @@ func (c *CPAField) SanitizeAndValidate() *AppError {
|
||||
}
|
||||
|
||||
if err := options.IsValid(); err != nil {
|
||||
return NewAppError("ValidateCPAField", "app.custom_profile_attributes.invalid_options.app_error", nil, "", http.StatusUnprocessableEntity).Wrap(err)
|
||||
return NewAppError("SanitizeAndValidate", "app.custom_profile_attributes.sanitize_and_validate.app_error", map[string]any{
|
||||
"AttributeName": PropertyFieldAttributeOptions,
|
||||
"Reason": err.Error(),
|
||||
}, "", http.StatusUnprocessableEntity).Wrap(err)
|
||||
}
|
||||
c.Attrs.Options = options
|
||||
}
|
||||
@@ -160,7 +166,10 @@ func (c *CPAField) SanitizeAndValidate() *AppError {
|
||||
visibility := CustomProfileAttributesVisibilityDefault
|
||||
if visibilityAttr := strings.TrimSpace(c.Attrs.Visibility); visibilityAttr != "" {
|
||||
if !IsKnownCPAVisibility(visibilityAttr) {
|
||||
return NewAppError("ValidateCPAField", "app.custom_profile_attributes.unknown_visibility.app_error", map[string]any{"Visibility": visibilityAttr}, "", http.StatusUnprocessableEntity)
|
||||
return NewAppError("SanitizeAndValidate", "app.custom_profile_attributes.sanitize_and_validate.app_error", map[string]any{
|
||||
"AttributeName": CustomProfileAttributesPropertyAttrsVisibility,
|
||||
"Reason": "unknown visibility",
|
||||
}, "", http.StatusUnprocessableEntity)
|
||||
}
|
||||
visibility = visibilityAttr
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user