AtomLinter / linter-eslint

ESLint plugin for Atom Linter
https://atom.io/packages/linter-eslint
584 stars 141 forks source link

[dev] Find a way to throw user facing errors in the workers #1420

Closed aminya closed 3 years ago

aminya commented 3 years ago

Issue Description

Currently, the worker errors use console.error if they are not fatal. For non-fatal errors, we should find a way to use a user-facing error like emit.

This means emitKey should be easily usable by worker functions that may fail.

This is how fatal errors are passed: https://github.com/AtomLinter/linter-eslint/blob/a4f551717d5a74a65579f17a295ffb36cd731a68/src/worker.js#L82

Because they are fatal, try-catch captures them.

The solution could be storing emitKey in a WeakMap and export it from worker.js. This allows worker-helpers.js to use emitKey without the need to pass it as a function parameter.

UziTech commented 3 years ago

Helpers.log is added in #1441