mirror of
https://github.com/apache/superset.git
synced 2026-04-20 00:24:38 +00:00
feat: generic marshmallow error component (#25303)
This commit is contained in:
@@ -332,7 +332,6 @@ class DatasetRestApi(BaseSupersetModelRestApi):
|
||||
|
||||
@expose("/<pk>", methods=("PUT",))
|
||||
@protect()
|
||||
@safe
|
||||
@statsd_metrics
|
||||
@event_logger.log_this_with_context(
|
||||
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.put",
|
||||
|
||||
@@ -24,6 +24,7 @@ from marshmallow.validate import Length
|
||||
from marshmallow_sqlalchemy import SQLAlchemyAutoSchema
|
||||
|
||||
from superset.datasets.models import Dataset
|
||||
from superset.exceptions import SupersetMarshmallowValidationError
|
||||
|
||||
get_delete_ids_schema = {"type": "array", "items": {"type": "integer"}}
|
||||
get_export_ids_schema = {"type": "array", "items": {"type": "integer"}}
|
||||
@@ -125,6 +126,17 @@ class DatasetPutSchema(Schema):
|
||||
is_managed_externally = fields.Boolean(allow_none=True, dump_default=False)
|
||||
external_url = fields.String(allow_none=True)
|
||||
|
||||
def handle_error(
|
||||
self,
|
||||
error: ValidationError,
|
||||
data: dict[str, Any],
|
||||
**kwargs: Any,
|
||||
) -> None:
|
||||
"""
|
||||
Return SIP-40 error.
|
||||
"""
|
||||
raise SupersetMarshmallowValidationError(error, data)
|
||||
|
||||
|
||||
class DatasetDuplicateSchema(Schema):
|
||||
base_model_id = fields.Integer(required=True)
|
||||
|
||||
Reference in New Issue
Block a user