Is there a way to catch a query error?

edited November 2, 2017 in Questions
In some predictable cases, a query will fail and user friendly messages could be given to the user to correct their mistake. Is there a way to catch this error in JavaScript like the 'add-on error' action in the action framework? When doing a try catch in JavaScript snippets, the error doesn't get caught, and the jQuery promise is resolved.

I also tried subscribing to 'models.load' events but the event only fired on success of updateData()  and it seems to consider an updateData() call a success even when the query error message pops up
loaded
PUBLISHED:
at the end of a successful call to model.updateData()
https://docs.skuid.com/latest/en/skuid/api/skuid_events.html?#skuid.events.models.loaded


Comments

  • edited November 2, 2017
    Thanks for your question!  Have you tried a callback function within the updateData call?
    model.updateData(function(result) {
         if (result.totalsuccess) {
              // Do something on success
         else {
              // Do something on failure 
         }
    }));
    Hope this helps you out!

    Christine
  • edited December 12, 2016
    Thanks, I hadn't tried it. I just tried it and although I'm setting the failure to do nothing, I still get the error in the screenshot below. Here's the relevant code .
            dfrd = attachmentsMod.updateData(function(result) {            
                if (!result.totalsuccess) {
                // Do nothing on fail
                }
            });
    I'm returning this deferred Jquery object later on.

    Here's a screenshot of the error.

    image
  • edited November 2, 2017
    I ended up passing this to apex, handling it there, and working off of the returned result.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!