middleware/_modelIndex.js
function handleQueryError (err) {

        queryErrorCount++;

        // Something has gone terribly wrong. Break from loop.
        if (queryErrorCount > 1) {

            // Reset all filters.
            session.list.formData = {};

            // Notify the user that an error has occured.
            req.linz.notifications.push(linz.api.views.notification({
                text: 'One of the filters is repeatedly generating an error. All filters have been removed.',
                type: 'error'
            }));

            // Rerun the query at the last known working state.
            // eslint-disable-next-line no-use-before-define
            return getModelIndex();

        }

        // Reset the last known working state.
        session.list.formData = session.list.previous.formData;

        // If we're in development mode, return the error
        // so that the developers are aware of it and can fix it.
        if (isDevelopment) {
            return next(err);
        }

        // Notify the user that an error has occured.
        req.linz.notifications.push(linz.api.views.notification({
            text: 'An error has occured with one of the filters you added. It has been removed.',
            type: 'error'
        }));

        // Rerun the query at the last known working state.
        // eslint-disable-next-line no-use-before-define
        return getModelIndex();

    }
function handleQueryError (err) {

        queryErrorCount++;

        // Something has gone terribly wrong. Break from loop.
        if (queryErrorCount > 1) {

            // Reset all filters.
            session.list.formData = {};

            // Notify the user that an error has occured.
            req.linz.notifications.push(linz.api.views.notification({
                text: 'One of the filters is repeatedly generating an error. All filters have been removed.',
                type: 'error'
            }));

            // Rerun the query at the last known working state.
            // eslint-disable-next-line no-use-before-define
            return getModelIndex();

        }

        // Reset the last known working state.
        session.list.formData = session.list.previous.formData;

        // If we're in development mode, return the error
        // so that the developers are aware of it and can fix it.
        if (isDevelopment) {
            return next(err);
        }

        // Notify the user that an error has occured.
        req.linz.notifications.push(linz.api.views.notification({
            text: 'An error has occured with one of the filters you added. It has been removed.',
            type: 'error'
        }));

        // Rerun the query at the last known working state.
        // eslint-disable-next-line no-use-before-define
        return getModelIndex();

    }
function handleQueryError ( err ) { queryErrorCount ++ ; // Something has gone terribly wrong. Break from loop. if ( queryErrorCount > 1 ) { // Reset all filters. session . list . formData = { } ; // Notify the user that an error has occured. req . linz . notifications . push ( linz . api . views . notification ( { text : 'One of the filters is repeatedly generating an error. All filters have been removed.' , type : 'error' } ) ) ; // Rerun the query at the last known working state. // eslint-disable-next-line no-use-before-define return getModelIndex ( ) ; } // Reset the last known working state. session . list . formData = session . list . previous . formData ; // If we're in development mode, return the error // so that the developers are aware of it and can fix it. if ( isDevelopment ) { return next ( err ) ; } // Notify the user that an error has occured. req . linz . notifications . push ( linz . api . views . notification ( { text : 'An error has occured with one of the filters you added. It has been removed.' , type : 'error' } ) ) ; // Rerun the query at the last known working state. // eslint-disable-next-line no-use-before-define return getModelIndex ( ) ; }
This method should be executed when a query error is returned.
It will abort the current query and return the results of the previous query instead.
@return {Void}
This method should be executed when a query error is returned . It will abort the current query and return the results of the previous query instead .