Skip to content

Please add support onError action/event in server side code #359

Closed

Description

@hype11

There is no action/event to handle errors in a custom way at server side.
There is a property "Log" (in Devart.Data.Linq.DataContext) for logging statements etc. but nothing which is fired in error case.

Activity

  1. AlekseyMartynov commented on Jun 17, 2019

    @AlekseyMartynov
    Contributor

    You can catch and handle server errors using a try-catch block:

    try {
        // Use DataSourceLoader
    } catch(Exception x) {
        // handle the error
    }
  2. hype11 commented on Jun 25, 2019

    @hype11
    Author

    I use it in this way:
    DataSourceLoader.Load(IQueryable, DataSourceLoadOptions)
    The IQueryable is executed out of controller scope, so I cannot add a simple try-catch, because the IQueryable is executed in DevExpress logic or while serializing.
    I hope it's understandable.

  3. AlekseyMartynov commented on Jun 25, 2019

    @AlekseyMartynov
    Contributor

    Now I understand that you need to catch exceptions that occur during the delayed enumeration of the result.

    Possible solutions:

    1. Force JSON serialization

    try {
        var loadResult = DataSourceLoader.Load(source, loadOptions);
        return Content(JsonConvert.SerializeObject(loadResult), "application/json");
    } catch(Exception x) {
        // TODO
        throw;
    }

    2. Force enumeration (feature request #347)

    try {
        var loadResult = DataSourceLoader.Load(source, loadOptions);
        if(loadResult.data is IQueryable)
            loadResult.data = loadResult.data.Cast<Object>().ToArray();
        return loadResult;
    } catch(Exception x) {
        // TODO
        throw;
    }
  4. hype11 commented on Jun 27, 2019

    @hype11
    Author

    Thank you for your help. I implemented the executing of the Queryable. In my case I could not execute the query in all cases, because the "IsCountQuery"-request throws an exception. So in future, it would be nice to have a possiblity to add a logger function.

  5. AlekseyMartynov commented on Jul 1, 2019

    @AlekseyMartynov
    Contributor

    Thank you. I updated the code snippets. Now they handle IsCountQuery errors, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions