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

🛠️ Repo: Unify caught errors as err #5258

Open
3 tasks done
wnghdcjfe opened this issue Nov 17, 2024 · 2 comments
Open
3 tasks done

🛠️ Repo: Unify caught errors as err #5258

wnghdcjfe opened this issue Nov 17, 2024 · 2 comments
Labels
area: repository tooling concerning ease of contribution status: accepting prs Mocha can use your help with this one!

Comments

@wnghdcjfe
Copy link
Contributor

Feature Request Checklist

Overview

Sometimes the error is written as e, sometimes as err. Why don't we unify it as err?

      try {
        foundReporter = require.resolve(reporterName);
        reporter = require(foundReporter);
      } catch (err) {
        if (foundReporter) {
          throw createInvalidReporterError(err.message, foundReporter);
        }
        // Try to load reporters from a cwd-relative path
        try {
          reporter = require(path.resolve(reporterName));
        } catch (e) {
          throw createInvalidReporterError(e.message, reporterName);
        }
      }

Suggested Solution

      try {
        foundReporter = require.resolve(reporterName);
        reporter = require(foundReporter);
      } catch (err) {
        if (foundReporter) {
          throw createInvalidReporterError(err.message, foundReporter);
        }
        // Try to load reporters from a cwd-relative path
        try {
          reporter = require(path.resolve(reporterName));
        } catch (err) {
          throw createInvalidReporterError(err.message, reporterName);
        }
      }

Alternatives

.

Additional Info

.

@wnghdcjfe wnghdcjfe added status: in triage a maintainer should (re-)triage (review) this issue type: feature enhancement proposal labels Nov 17, 2024
@JoshuaKGoldberg JoshuaKGoldberg added area: repository tooling concerning ease of contribution and removed type: feature enhancement proposal labels Nov 17, 2024
@JoshuaKGoldberg
Copy link
Member

Hmm, this is a repository tooling request, not so much a feature request.

👍 from me on picking a name and sticking with it. As to which name... I personally prefer full names like error over abbreviations like err or e. But that's just me. @mochajs/maintenance-crew might have an opinion here.

@JoshuaKGoldberg JoshuaKGoldberg changed the title 🚀 Feature: Error naming unification 🛠️ Repo: Error naming unification Jan 2, 2025
@JoshuaKGoldberg JoshuaKGoldberg changed the title 🛠️ Repo: Error naming unification 🛠️ Repo: Unify caught errors as err Jan 2, 2025
@JoshuaKGoldberg
Copy link
Member

Ok just following up: nobody from the crew has input and as you noted @wnghdcjfe, the existing standard is err. So 👍 from me on just unifying on err.

@JoshuaKGoldberg JoshuaKGoldberg added status: accepting prs Mocha can use your help with this one! and removed status: in triage a maintainer should (re-)triage (review) this issue labels Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: repository tooling concerning ease of contribution status: accepting prs Mocha can use your help with this one!
Projects
None yet
2 participants