DEV Community

Discussion on: Let's Clean Up: Ugly Try-Catches!

Collapse
 
coly010 profile image
Colum Ferry

I understand what you're saying, and it makes sense. There's a cost to learning what the method does, but the same can be said for any dependency you add to your codebase.

Take for example someone adding lodash, are using both _.clone and _.cloneDeep but someone else comes along to read it. If they don't know about lodash, or the difference between those functions, they will have to go and look them up to.

Perhaps simply calling the function tryCatch might have explained more what the function is doing, BUT, for any dev that wants it to be called this, then they can alias the import.

import { noTry as tryCatch } from 'no-try';

Or

const tryCatch = require('no-try').noTry;