Better way to do switching.
npm i fluent-switch
FluentSwitch
.createFrom(error)
.case(e => e instanceof TimeoutError, e => log.error('timeout', e))
.case(e => e instanceof ConnectionError, () => e => log.error('connection', e))
.execute()
FluentSwitch
.createFrom(error)
.case(e => e instanceof TimeoutError, e => log.error('timeout', e))
.case(e => e instanceof ConnectionError, () => e => log.error('connection', e))
.else(e => log.error('Unknown error', e))
.execute()