W
W
Worddoc2017-10-06 12:03:21
JavaScript
Worddoc, 2017-10-06 12:03:21

What is the essence of the best pattern for writing code with catching all errors?

Hello.
Actually, I would like to know, what do you think the pattern of the best writing of code with catching errors looks like?
The only thing that comes to mind is not to run each function while the key element in this function is 'undefined', and if it is not equal to undefined, then run the function through try / catch. There are doubts about the performance of such code, although they are almost not confirmed by anything. What do you think about this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
X
xmoonlight, 2017-10-07
@Worddoc

There are expected behavior and expected values.
There are actual ones.
In addition to the implementation of the functionality for controlling all intermediate states of objects (the UML diagram state register) and variables in the executable code with the ability to quickly disable this functionality, there are no other ways and cannot be.

/*BEFORE*/
////////TEST SECTION N////////
if (TEST) {
  //test variables and object states (+update UML states registry)
}
//////END TEST SECTION N/////

/* MAIN WORK BLOCK CODE (from UML diagramm)
.....
*/

/*AFTER*/
////////TEST SECTION N////////
if (TEST) {
  //test variables and object states (+update UML states registry)
}
//////END TEST SECTION N/////

PS: in regex and especially in conditions - it's quite easy to make a mistake and not notice...

S
Stanislav Botev, 2017-10-12
@StasBotev

Use static typing: Flow or Typescript.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question