express-async-errors icon indicating copy to clipboard operation
express-async-errors copied to clipboard

Set function name to newFn

Open captDaylight opened this issue 6 years ago • 8 comments

Simply sets the function name to the new function during wrap.

Ref #16

captDaylight avatar Apr 09 '19 15:04 captDaylight

Thanks for the PR! This looks good to me.

@kronicker Can you think of any possible unintended consequences of this before we merge?

I think this is only a minor version bump, but can anyone think of a way it might break existing behaviour requiring a major?

davidbanham avatar Apr 10 '19 03:04 davidbanham

@davidbanham I don't think so. Express does not rely on function names anywhere, only on arity. Thinking about it, I think I wanted to do this originally. If we want to be nitpicky, wrapper function will now have the same name as the original wrapped one so they will appear with the same name in the stack, but I guess that's fine and still better then 'newFn'. The minor bump should be fine.

kronicker avatar Apr 23 '19 07:04 kronicker

Awesome! Thanks for taking a look. I'll release tomorrow.

davidbanham avatar Apr 23 '19 12:04 davidbanham

If we want to be nitpicky, wrapper function will now have the same name as the original wrapped one so they will appear with the same name in the stack, but I guess that's fine and still better then 'newFn'. The minor bump should be fine.

Let's be nitpicky cause this thing can easily confuse people and is pretty nonstandard :warning: Can we wait until @kevinburkenotion responds to https://github.com/davidbanham/express-async-errors/issues/16 ?

Regarding major/minor issue, FWIW I'm also in minor camp :+1:

vladimyr avatar Apr 24 '19 02:04 vladimyr

Yep, happy to hold off on the release while we wait to hear back on #16. Thanks, @vladimyr

davidbanham avatar Apr 24 '19 03:04 davidbanham

@vladimyr How about making it fn.name + 'Wrap' for not been confusing? 'Wrap' may be even something more specific, like 'throwHandlerWrap'

Alexsey avatar Jul 03 '19 13:07 Alexsey

Seems like we're all happy to move ahead on the fn.name + 'Wrap' mechanism?

@vladimyr does that work for you?

If there's no howls of dissent in the next week or so I'll update this PR with the Wrap suffix on the name and look to release it.

davidbanham avatar Aug 08 '19 03:08 davidbanham

@davidbanham are you going to change fn.name to fn.name ? fn.name + 'Wrap' : 'throwHandlerWrap'?

Alexsey avatar Oct 13 '19 16:10 Alexsey