- Home
- Forum
- ASP.NET Core - EJ 2
- Custom message for grid validation
Custom message for grid validation
1) throw new Exception("Error el registro se encuentra vinculado a otra tabla ");
2) return new BadRequestObjectResult(message);
toolbarClick="toolbarClick" toolbar="@(new List<string>() { "Add", "Edit", "Update", "ExcelExport", "Search", "Cancel", "Delete" })".......>
"Uncaught (in promise) TypeError: args.error"
|
HomeController.cs
public IActionResult Insert([FromBody]CRUDModel<Orders> Value)
{
try
{
. . . .
}
catch (Exception e) {
throw new Exception("Error el registro se encuentra vinculado a otra tabla");//message returns the exception content
}
} |
|
app.component.ts
function actionFailure(args) {
var errorMessage = args.error[0].error.responseText.split("Exception:")[1].split("</div>")[0];
console.log(errorMessage) //Get error message here
}
|
Hi,
I have the same issue here, instead of the error I got on actionFailure:
"Error at https://localhost:44312/js/ej2/ej2.min.js:1:763649"
Hi Lucian,
Greetings from Syncfusion support.
We are glad to announce that we have included we have included the fix for “In actionFailure, failure message is not sent properly in latest version” in the latest version 23.1.41. We suspect you are using a older version of the EJ2, hence we suggest you to update to the latest version. To obtain a custom error message from the server-side within the actionFailure event argument during a fetch operation, use the text() method within the await statement to retrieve the custom error message from the server side. Please refer the below code example and sample for more information.
|
<script> async function actionFailure(args) { if (args && args.error && args.error[0] && args.error[0].error) { try { const response = await args.error[0].error.text(); const errorMessage = response.split("Exception:")[1].split('\n')[0].slice(1); alert(errorMessage); } catch (error) { console.error("Error reading the error message: " + error); } } } </script>
|
Regards,
Joseph I.
- 3 Replies
- 4 Participants
- Marked answer
-
JA Javier A Aguilera
- Aug 25, 2020 06:42 PM UTC
- Nov 14, 2023 09:24 AM UTC