Revision 7618eba2

b/doc/dev-codestyle.rst
476 476

  
477 477
Similarly, provide Haddock-style comments for top-level definitions.
478 478

  
479
Use sum types instead of exceptions
480
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
481

  
482
Exceptions make it hard to write functional code, as alternative
483
control flows need to be considered and compiler support is limited.
484
Therefore, Ganeti functions should never allow exceptions to escape.
485
Function that can fail should report failure by returning an appropriate
486
sum type (``Either`` or one of its glorified variants like ``Maybe`` or
487
``Result``); the preferred sum type for reporting errors is ``Result``.
488

  
489
As other Ganeti functions also follow these guide lines, they can safely
490
be composed. However, be careful when using functions from other libraries;
491
if they can raise exceptions, catch them, preferably as close to their
492
origin as reasonably possible.
493

  
479 494
Parentheses, point free style
480 495
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
481 496

  

Also available in: Unified diff