Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exceptions raised by ui-grid or ui-grid plugin code is caught and not logged in the console #7211

Open
julie4754 opened this issue Feb 15, 2022 · 2 comments

Comments

@julie4754
Copy link

When an exception is raised, the end of the following code:

function startProcessor(i, renderedRowsToProcess) {
      // Get the processor at 'i'
      var processor = self.rowsProcessors[i].processor;

      // Call the processor, passing in the rows to process and the current columns
      //   (note: it's wrapped in $q.when() in case the processor does not return a promise)
      return $q.when( processor.call(self, renderedRowsToProcess, self.columns) )
        .then(function handleProcessedRows(processedRows) {
          // Check for errors
          if (!processedRows) {
            throw "Processor at index " + i + " did not return a set of renderable rows";
          }

          if (!angular.isArray(processedRows)) {
            throw "Processor at index " + i + " did not return an array";
          }

         // Processor is done, increment the counter
          i++;

          // If we're not done with the processors, call the next one
          if (i <= self.rowsProcessors.length - 1) {
            return startProcessor(i, processedRows);
          }
          // We're done! Resolve the 'finished' promise
          else {
            finished.resolve(processedRows);
          }
        }).catch(angular.noop);
    }

In the original code, the exception is rethrown using the following code.

}).catch(function(error) {
    throw error;
});

The reason for raising this bug is that when using the ui-grid-auto-fit-columns plugin with in empty array of columnDefs, the plugin throws an exception but this exception cannot be seen in the console log to see the reason why the plugin is not working.

@stale
Copy link

stale bot commented Apr 17, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@oohsai
Copy link

oohsai commented Aug 9, 2023

Hey! I did some research over this. You can probably replace the string-based error messages with Error objects and add a catch block that logs the error to the console and then re-throws it. This allows the exception to propagate up the promise chain, ensuring that it's visible in the console.
/* .catch(function handleError(error) {
console.error("Error in startProcessor:", error);
throw error; // Re-throw the error to allow it to propagate
}); */

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

No branches or pull requests

3 participants