Do not throw when possible
tshemsedinov opened this issue · 0 comments
tshemsedinov commented
I propose to change throwing errors to errors returning (bubbling) in following places:
- Parsing errors:
SyntaxError
becausethrow/try/catch
pattern gives less performance then justreturn new Erorr()
- Calling application method, here we can catch error and bubble it to callback but not throwing
- Multiple instances of application with different same the name
- In
Connection
constructor where at least one of parameters is requiredclient
orserver
- Implicit throwing
TypeError
for example accessing data structures, function parameters, especially callbacks. But not all implicit throwing should be bubbled and even may be bubbled of course.
I know that it is not common practice in JS but such approach is better for performance and server application stability. @metarhia/jstp-core please express your arguments.