Server provided errors handling
Server provided errors handling
ralfeus
Posts: 24Questions: 6Answers: 1
Hi all,
how exactly server side provided errors are handled by the Editor? I read this article but it describes only format of the data returned, which I've implemented.
However I don't see those messages in my frontend. Should I also implement it in postSubmit
handler? Or it should be done somehow automatically?
This discussion has been closed.
Replies
I have found this article saying:
Having that in mind I expected that this code would work fine (will show proper errors):
In case of error (validation error) I return following (HTTP 400):
However no my error messages were shown on the edit form - just a standard "A system error has occurred (More information)." one.
So I've changed an error handler to this:
Then field error messages were shown. However the general error message (
Couldn't save a payment
) wasn't shown. Instead the standard one was. And if I don't callerror_callback(xhr, error, status)
the message is shown then but the submit process never ends.From the description I understand the JSON I return is invalid. But I believe I've constructed it according to the documentation. What could I miss? Or it's a bug?
It should be completely automatic as you indicate in your second post.
In this case you have provided your own
ajax
function, which is going to complicate things. Can I suggest you use:That will allow Editor to perform its own error handling, including the 400 error.
Regards,
Allan