Hello,
I try to handle server error response after an event delete. My goal is to display a Toast with the returned error message.
My eventSore :
const eventStore = new bryntum.scheduler.EventStore({
modelClass : kaplanAssignment,
createUrl : 'path/to/my/dotnet/controller/Create/',
readUrl : 'path/to/my/dotnet/controller/Load/',
updateUrl : 'path/to/my/dotnet/controller/Update',
deleteUrl : 'path/to/my/dotnet/controller/Delete',
autoLoad : true,
autoCommit : true,
});
My understanding of the https://www.bryntum.com/docs/scheduler/#Core/data/AjaxStore#event-exception is that the Exception event should fire when the server response (of the Delete auto-commit) is a 400 http code.
So I set my listeners like this :
listeners : {
exception({action, exceptionType, response}) {
bryntum.scheduler.Toast.show({
color: 'b-red',
html: response.parsedJson.message,
showProgress: false
});
}
}
And for testing purpose I set my dotnet controller to return a json response like this :
{"message":"unexpected error","success":false}
using the following c# code:
// send a response with 400 statusCode
return BadRequest(new SchedulerErrorResponse {
success = false,
message = "unexpected error"
});
Here is the result :
- the Exception event never fires when I click the Delete button of the
eventEditor
- I have an uncaught exception in dev tools : Note that the Uncaught error contains an object that complies with the documentation.
I tried to set the server response with a 200 statusCode
, thinking that the success
property of the response body would suffice to fire the event but it doesn't work either. But in this case I no longer have an uncaught error in dev tools.
What am I missing out? What are the expected situations where the Exception event is supposed to fire?
Thx,
Edouard