question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is there a way to define a global error handler?

See original GitHub issue

Looking for a way to define a global error handler on my axios instance.

I tried this but the error block doesn’t ever execute even when I take my backend down.

// set a default response handler
axios.interceptors.response.use(res => {
  return res;
}, err => {
  debugger;
  console.error(err);
  return Promise.reject(err);
});

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:6
  • Comments:10

github_iconTop GitHub Comments

56reactions
falostcommented, Nov 14, 2018

update your os

在 2018年11月14日,07:13,liulun notifications@github.com 写道:

How about this issue’s progressing?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/axios/axios/issues/1600#issuecomment-438474222, or mute the thread https://github.com/notifications/unsubscribe-auth/ANEvM-pBGGRhlXEh3lVHBKYJIh7l7Ibvks5uu1IIgaJpZM4UjKT6.

34reactions
tarekadamcommented, Jan 14, 2019

I set up global error handling with interceptors. https://github.com/axios/axios#interceptors

axios.interceptors.response.use(function (response) {
    // Do something with response data
    return response;
  }, function (error) {
    // Do something with response error
    return Promise.reject(error);
  });
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to create a Global Error Handler in Mule 4 to unify your ...
Steps for phase 2 implementation: Defining “Global Error Handler Configuration”. Step 1: Select the “Global Elements” tab in Anypoint Studio.
Read more >
Global Error Handling with Angular2+ | by Austin - Medium
Whatever you're doing in this logic, here's how we go about it… First, let's define a GlobalErrorHandler class that will inherit from ErrorHandler...
Read more >
Global Exception Handler - UiPath Documentation Portal
The Global Exception Handler is a type of workflow designed to determine the project's behavior when encountering an execution error.
Read more >
Global Error Handler - Better StimulusJS
First define a global Application Controller that your Stimulus controllers ... Stimulus includes a largely undocumented error handler (see links below).
Read more >
Java Global Exception Handler - Baeldung
In this article, we took time to understand what the exceptions are, and what are the basic ways to handle them. Also, we...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found