Script Raccoon @scriptraccoon.dev · Jan 27

Sometimes I run into this situation that I have code duplication in a function and I cannot get rid of it. Have a look at this example. I repeat twice "return fail(500, ...)". A utility func will only return from itself. I need a construct that "returns in the parent". Try-catch is boilerplatey.

0 likes 1 replies

?

Replies

David Dal Busco · Jan 27

Which framework are you using? I recently implemented an API with ElysiaJS and used their "custom error" handling to avoid the boilerplate. With it, you can throw exceptions anywhere and map return types globally once. elysiajs.com/patterns/err...