Closed aminya closed 3 years ago
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.
console.error
emit
This means emitKey should be easily usable by worker functions that may fail.
emitKey
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.
WeakMap
worker.js
worker-helpers.js
Helpers.log is added in #1441
Helpers.log
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 likeemit
.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 aWeakMap
and export it fromworker.js
. This allowsworker-helpers.js
to useemitKey
without the need to pass it as a function parameter.