From 0b6e0d203a184a2bdc258a5198246286e8a0945f Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Thu, 19 Dec 2024 22:06:22 +0000 Subject: [PATCH] [5.x] Improve error handling when using entry publish actions (#11289) Co-authored-by: Jason Varga --- resources/js/components/entries/PublishActions.vue | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/resources/js/components/entries/PublishActions.vue b/resources/js/components/entries/PublishActions.vue index cb728be372..6fb7919f6c 100644 --- a/resources/js/components/entries/PublishActions.vue +++ b/resources/js/components/entries/PublishActions.vue @@ -216,8 +216,20 @@ export default { }, handleAxiosError(e) { + if (e.response && e.response.status === 422) { + const { message, errors } = e.response.data; + this.error = message; + this.errors = errors; + this.$toast.error(message); + this.$reveal.invalid(); + } else if (e.response) { + this.$toast.error(e.response.data.message); + } else { + this.$toast.error(e || 'Something went wrong'); + } + this.saving = false; - this.$toast.error(e || __('Something went wrong')); + this.$emit('failed'); } }