PanJiaChen/vue-admin-template · error

error || 'Has Error'

Error message

error || 'Has Error'

What it means

Fallback message in the global router guard: shown when store.dispatch('user/getInfo') throws during navigation (empty user data, invalid/expired token, or network failure); the guard then resets the token, shows the error (or the 'Has Error' sentinel when the rejection was falsy) and redirects to /login with a redirect query.

Source

Thrown at src/permission.js:41

  if (hasToken) {
    if (to.path === '/login') {
      // if is logged in, redirect to the home page
      next({ path: '/' })
      NProgress.done()
    } else {
      const hasGetUserInfo = store.getters.name
      if (hasGetUserInfo) {
        next()
      } else {
        try {
          // get user info
          await store.dispatch('user/getInfo')

          next()
        } catch (error) {
          // remove token and go to login page to re-login
          await store.dispatch('user/resetToken')
          Message.error(error || 'Has Error')
          next(`/login?redirect=${to.path}`)
          NProgress.done()
        }
      }
    }
  } else {
    /* has no token*/

    if (whiteList.indexOf(to.path) !== -1) {
      // in the free login whitelist, go directly
      next()
    } else {
      // other pages that do not have permission to access are redirected to the login page.
      next(`/login?redirect=${to.path}`)
      NProgress.done()
    }
  }
})

View on GitHub (pinned to 4c18a3f47b)

Solutions

  1. Re-authenticate via the login page the guard redirects to
  2. Ensure getInfo rejects with a non-empty Error so the real cause is displayed instead of the sentinel
  3. Check backend availability and token validity if the error recurs on every navigation
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at src/permission.js:41 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of PanJiaChen/vue-admin-template@4c18a3f47b (2026-09-02). Data as JSON: /api/errors/0e67c5428b209417. Report an issue: GitHub.