Datagrid OnActionFailure Event error details

Is it possible to get the Exception object from theSyncfusion.Blazor.Grids.FailureEventArgs object? It looks like there is only one public property, "Error" and this appears to be the string representation of the exception rather than the object that was thrown. I need to handle different exceptions differently so working with the original exception object is necessary.

7 Replies

RN Rahul Narayanasamy Syncfusion Team June 4, 2020 04:20 PM UTC

Hi Chet, 

Greetings from Syncfusion. 

Query: Is it possible to get the Exception object from theSyncfusion.Blazor.Grids.FailureEventArgs object? 

We have validated your query and by default the OnActionFailure event argument will be an object. If you want the error or other details, you can get it by using below way. Find the below code snippets and screenshot for your reference. 

 
    <SfGrid DataSource="@Employees" AllowPaging="true" Height="315" Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update" })"> 
        <GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true"></GridEditSettings> 
        <GridEvents OnActionFailure="ActionFailureHandler" TValue="EmployeeData"></GridEvents> 
        . . . 
    </SfGrid> 
 
@code{ 
    public List<EmployeeData> Employees { get; set; } 
 
    . . . 
    public void ActionFailureHandler(FailureEventArgs args) 
    { 
        var s = JsonConvert.DeserializeObject<Dictionary<string, object>>(JsonConvert.SerializeObject(args.Error));  //get details 
    } 
} 

 

If you are still facing any difficulties, could you please share the below details. It will be helpful to validate and provide a better solution. 

  • Syncfusion NuGet version details.
  • Exact requirement.

Regards, 
Rahul 



CH Chet June 5, 2020 02:11 AM UTC

Version is 18.1.0.55, using server side Blazor (have not attempted in WebAssembly).

Using a custom data adapter... 

Behavior we are seeing....   
  • When exception is thrown from the UpdateAsync(.....), InsertAsync(....) or RemoveAsync(....) method, FailureEventArgs.Error is a plain string.  
  • When exception is thrown from the Read(....) method, is a FailureEventArgs.Error Newtonsoft.Json.Linq.JObject
The JSON is obviously object is obviously easier to work with, so that would be preferred in all cases if that were consistent.  However it would be ideal if you could simply pass the original exception that was thrown in the FailureEventArgs... in the .Error property or even new property.




NI Nicola June 5, 2020 02:47 PM UTC

Hi,

from WebAssembly I cannot deserialize FailureEventArgs.

This doesn't work:

public void ActionFailureHandler(Syncfusion.Blazor.Grids.FailureEventArgs args)

{

    var s = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, object>>(Newtonsoft.Json.JsonConvert.SerializeObject(args.Error));  //get details 

}


Any idea?

Thanks in advance

Nicola




RN Rahul Narayanasamy Syncfusion Team June 10, 2020 03:18 AM UTC

Hi Chet, 

Thanks for your update. 

We have validated your query and able to reproduce the reported problem. We have confirmed this as a bug and logged defect report for the same ActionFaliure event arguments not proper when error is thrown from CRUD opertion. At Syncfusion, we are committed to fixing all validated defects (subject to technological feasibility and Product Development Life Cycle ) and including the defect fix in our upcoming Volume 2 release which is expected to be rolled out by the end of June, 2020. 
   
You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link.   
 

Please get back to us if you need further assistance.  

Regards, 
Rahul 



RN Rahul Narayanasamy Syncfusion Team June 10, 2020 03:19 AM UTC

Hi Nicola, 

Greetings from Syncfusion. 

We have validated your query and we suspect that you have faced the problem while exception thrown from CRUD oprations. If yes, we have already logged a defect report for the same ActionFaliure event arguments not proper when error is thrown from CRUD opertion. At Syncfusion, we are committed to fixing all validated defects (subject to technological feasibility and Product Development Life Cycle ) and including the defect fix in our upcoming Volume 2 release which is expected to be rolled out by the end of June, 2020. 
   
You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link.   
 

Or if you have faced the problem in any other case, then could you please share more information regarding your scenario. It will be helpful to validate further. 
 
  • Exact scenario of the problem.
  • Full Grid code snippets.
 
Regards, 
Rahul 
 



AN Andrew November 28, 2020 12:52 PM UTC

Hello,

I am having a similar situation but the error coming back from the 'FailureEventArgs args' is: 
"Response status code does not indicate success: 500 (Internal Server Error)."
I am guessing this is because its the HttpResponse Error that it is receiving from the WebApi? 

<GridEvents OnActionFailure="ActionFailure" TValue="ResponseType"></GridEvents>
                                <SfDataManager Url="api/Responsetypes"
                                Adaptor="Adaptors.WebApiAdaptor">
</SfDataManager>

How do I pass back the correct result to the ActionFailureHandler(FailureEventArgs args) ?

[HttpPost]
        public object Post([FromBody] ResponseType ResponseType)
        {
            try
            {
                _dataAccess.AddResponseType(ResponseType);
            }
            catch (Exception ex)
            {
                return ex;
            }
                
            return ResponseType;
        }


VN Vignesh Natarajan Syncfusion Team November 30, 2020 01:14 PM UTC

Hi Andrew,  
 
Thanks for contacting Syncfusion support.  
 
Query: “How do I pass back the correct result to the ActionFailureHandler(FailureEventArgs args) ? 
 
We have analyzed your query and we are quite unclear about your requirement. So kindly share the following detail to validate the reported query at our end.  
 
  1. Do you want to ActionFailure event to be trigger when exception is thrown manually in POST method?
  2. Share the more details about the error you are receiving from WEBAPI (i.e.) are you facing issue during initial rendering or during a certain action.
  3. Are you facing exception while inserting a record in your server.
  4. Also share the error details thrown in ActionFailure event arguments.
  5. Kindly share more details about the query you are facing.
 
Above requested details will be helpful for us to validate the reported query at our end and provide solution as early as possible.  
 
Regards, 
Vignesh Natarajan   
 
 


Loader.
Up arrow icon