metarhia/jstp

Do not throw when possible

tshemsedinov opened this issue · 0 comments

I propose to change throwing errors to errors returning (bubbling) in following places:

  • Parsing errors: SyntaxError because throw/try/catch pattern gives less performance then just return 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 required client or server
  • 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.