nextcloud / nextcloud/spreed

Improve error handling

Open
#9,404 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement feature: frontend 🖌️ technical debt
Dominant language
PHP
Stars
2.2k
Forks
587
Avg merge
18h 27m
Merged PRs (30d)
333

Description

How to use GitHub
  • Please use the 👍 reaction to show that you are interested into the same feature.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

1. Do not use console.debug for errors, use console.error if necessary

We also use console.info and console.warn sometimes. Shouldn't we use console.debug only for debugging related stuff?

Why: Errors should be logged as errors, they have a separate place in the dev tools and display

Examples:

try {
  await foo()
} catch (error) {
  // ❌
  console.debug(error)
  // ✅
  console.error(error)
}

2. Do not catch an exception, if it is not required

Catch an exception in case:

  1. You need special processing
  2. An exception here may break something

Why: a caught exception is "missed" from further processing

Examples:

try {
  await foo()
} catch(error) {
  // ❌ Catch just in case
  console.error(error)
}

try {
  await foo()
} catch(error) {
  // ✅ Some special processing, for example
  // ...showing a toast
  showError(error.message)
  // ...work with the exception
  if (error.responsestatusCode === 404) {
    // Special case
  }
}

// 📁 someStore.js
const actions = {
  someAction({ commit }) {
    try {
      commit('FOO')
      await foo()
    } catch(error) {
      // ✅ Need to revert changes
      commit('REVERT_FOO')
      }
    }
  }
}

// 📁 Component.vue
export default {
  async created() {
    try {
      await foo()
    } catch(error) {
      // ✅ The component mounting will be failed without catching the error
      // Some processing
    }
  },
}

3. Don't forget to re-throw an exception if it may not be processed

Why: Otherwise it is missed

Example:

try {
  await foo()
} catch(error) {
  if (error.responsestatusCode === 418) {
    // ...Custom processing...
  } else {
    // ✅
    // What if the error is not 418 ?
    throw error
  }
}

4. Think about possible exceptions and errors

try {
  await foo()
} catch(error) {
  // What may go wrong in `foo`?
  // Only general unexpected exceptions? Or also some domain-level errors?
  // May there be special results of `foo` that we need to proceed implicitly?
}

5. General errors

In case an error required special processing (for example, displaying a special message) and it is some specific action error, some general app-wide error - add general catching.

For example:

  • axios interception
  • Top-level window.addEventListener('error') or app level catch
  • Top-level window.addEventListener('unhandledPromiseRejection') or app level catch

See also

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no repository files or tests; start by locating uses of console.debug, console.info, console.warn, and broad try/catch blocks in the JavaScript and Vue code. Review the existing axios and window-level error-handling entry points, then define the project-wide scope before changing behavior. Done means errors are logged, propagated, re-thrown, or specially handled consistently without swallowing failures.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
22/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.