Skip to content

Latest commit

 

History

History
19 lines (14 loc) · 388 Bytes

no-throw.md

File metadata and controls

19 lines (14 loc) · 388 Bytes

Forbid the use of throw

Instead of throwing an error, return an object containing the description of the error, or use a tool like Either that you can find in some functional libraries.

Fail

function throwAnError() {
  throw new Error('some error message');
}

Pass

function returnAnError() {
  return Either.Left(new Error('some error message'));
}