How does axios in vue report errors in the log?

it is understood that axios"s interceptor cannot intercept error messages in .catch, so that if there is a undefined in .then, it will not be intercepted, but can only get error messages in .catch, and if there are multiple axios in the page, each catch is particularly troublesome, is there a global catch or any other better way to achieve catch error reporting?

Apr.21,2021

window.addEventListener('unhandledrejection', event => );

I think this question is open to question.

Why should an error returned by the interface be reported? In theory, the interface can return errors. The interface can catch errors on its own. Why not send these logs directly to the backend for processing? The front end should still deal with the errors related to the user, that is, let the user understand the error and proceed to the next step correctly.

if you really want to record and report all errors, you can only encapsulate an axios, to intercept all returns, and then continue after processing, which is no trouble.


can be intercepted through axios.interceptors.response . At the same time, the response result can be encapsulated, and error handling (reporting) will be carried out without throwing reject:, such as error code 200300.

{
  code: 404,
  message: 'Not Found'
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e5b4ed-45618.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e5b4ed-45618.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?