Global error handler in apps

I hope there's a better way to do this already that I'm missing, but here's my thoughts:

Use case - I need to log errors for later analysis, and be alerted when errors are happening in my apps

Current situation - I create a slack query that sends messages to a monitored channel.
I then have to wire every query to send data to that slack query in the failure event handler. Extra complication is that the slack error handler query needs details about what failed and why and the event handler dialog doesn't have additionalScope or a way to pass parameters, so I have to use runScript to trigger the query.

Ideal situation - nominate a resource as a global error handler for all app queries that automatically receives the query error/context/user/app/ etc and be able to enable this at a global level in addition to individual queries being able to have their own error handlers.

Perfect situation - Also be able to choose the "show notification on success/failure" checkbox option at the app level

1 Like

Hey @dcartlidge! I think you're probably doing the right thing...out of curiosity, what kind of errors are you looking to log? Just general query errors?

And I filed requests for both adding additionalScope inputs to the trigger event and for enabling failure/success handling at the app level!

That's perfect, thank you!

And, yep any/all errors that occur - I have a particular app with an autosave feature in it that users expect to be bulletproof so trapping everything that might go amiss is vital. Aside from that I need to know when queries fail due to a test case I'd not expected etc.

Hi @dcartlidge,

I'm sure this will get added in time, in the meanwhile we're using an implementation like this:

Main JS query to manage failures

var queryData;
const queryOmits = ['dataArray', 'rawData', 'transformer', 'errorTransformer', 'query'];

const cleanedQueryData = _.omit(queryData, queryOmits);
const metadata = {
  currentUser: _.omit(_.cloneDeep(current_user), 'groups'),
  localStorage: _.cloneDeep(localStorage.values),
  retoolContext: _.cloneDeep(retoolContext),
  urlparams: _.cloneDeep(urlparams),
  viewport: _.cloneDeep(viewport),
  navigator: {
    userAgent: window.navigator.userAgent,
    platform: window.navigator.platform

And then on each query we want to monitor we add a "Run script" failure handler:

  additionalScope: {
    queryData: self
1 Like

@dcartlidge is that Autosave feature something for when users are typing into a text area, for example? If so, is that a retool component or something you built to work in Retool?

yes that's what I use it for, as changes are made they are saved (after a pause in user activity) without them hitting a save button - it's hand crafted, I don't believe there's such a component or option out-of-the-box