koajs / koa-body

koa body parser middleware
MIT License
950 stars 130 forks source link

Shorten syntax on catch #42

Closed dlau closed 8 years ago

dlau commented 8 years ago

Following up on #41 -

Opinions/objections?

unDemian commented 8 years ago

Honestly I'm fine with how things are. if (!opts.onError) throw parsingError; opts.onError(parsingError, this); I don't like this version because the user can send stuff like onError = {} and it will throw an error. Now about the brackets I see there are a lot of opinionated people. I invite them to create a PR with less lines.

tunnckoCore commented 8 years ago

That's just enough. Then just one if check would work.

I think @dlau should start use some extend package for so many options.

edit: @unDemian agree.

unDemian commented 8 years ago

@tunnckoCore You are trying to optimize the use of brackets but you have 2 conditionals. One for checking the type then one for checking the true / false value. I did that with one check.

I don't really have time for this. If you like that short catch so much please push the code here. I tried helping but I really don't have time for this kind of "conflicts".

Have a great day

tunnckoCore commented 8 years ago

I don't have problems, it's not my package anymore. I have more stable and older package, with much more features and great code.

One for checking the type then one for checking the true / false value.

I just want to allow users to not have problems if onError or onerror is given. In anyway, i don't think it is needed et al, because koa has onerror.