Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add a section on errors and exceptions to the API documentation
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Sat, 21 Jan 2023 21:53:41 +0000 (22:53 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Sat, 21 Jan 2023 21:53:41 +0000 (22:53 +0100)
ChangeLog
docs/source/Doxyfile
docs/source/app_s4u.rst
include/simgrid/Exception.hpp
include/simgrid/forward.h

index 313343a..eed2b3e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -37,6 +37,7 @@ sthread:
 Documentation:
  - New section in the user guide on the provided performance models.
  - New section presenting some technical good practices for (potential) contributors.
+ - Add a section on errors and exceptions to the API documentation.
 
 Fixed bugs (FG#.. -> FramaGit bugs; FG!.. -> FG merge requests)
  (FG: issues on Framagit; GH: issues on GitHub)
index c1746d9..db9ec7e 100644 (file)
@@ -9,6 +9,7 @@ INPUT                 += ../../include/simgrid/comm.h
 INPUT                 += ../../include/simgrid/cond.h
 INPUT                 += ../../include/simgrid/engine.h
 INPUT                 += ../../include/simgrid/exec.h
+INPUT                 += ../../include/simgrid/Exception.hpp
 INPUT                 += ../../include/simgrid/host.h
 INPUT                 += ../../src/s4u/s4u_Host.cpp
 #INPUT                 += ../../include/simgrid/instr.h
index ff3a4f3..42bf128 100644 (file)
@@ -2765,6 +2765,55 @@ Locking
          .. doxygenfunction:: sg_sem_release(sg_sem_t sem)
          .. doxygenfunction:: sg_sem_would_block(const_sg_sem_t sem)
 
+===============
+Error reporting
+===============
+
+.. tabs::
+
+   .. group-tab:: C++
+
+      .. doxygenclass:: simgrid::Exception
+
+      The following exceptions denote a problem in the simulated platform, and it is often useful to catch them.
+
+      .. doxygenclass:: simgrid::CancelException
+      .. doxygenclass:: simgrid::HostFailureException
+      .. doxygenclass:: simgrid::NetworkFailureException
+      .. doxygenclass:: simgrid::StorageFailureException
+      .. doxygenclass:: simgrid::TimeoutException
+      .. doxygenclass:: simgrid::VmFailureException
+
+      The following errors denote a problem in the SimGrid tool itself. Most of the time, you should let these
+      exception go, so that the simulation stops. But you may want to catch them, for example when you launch
+      simgrid from a python notebook and want to handle the problem accordingly.
+
+      .. doxygenclass:: simgrid::AssertionError
+      .. doxygenclass:: simgrid::ParseError
+      .. doxygenclass:: simgrid::TracingError
+
+   .. group-tab:: Python
+
+      The following exceptions denote a problem in the simulated platform, and it is often useful to catch them.
+
+      .. autoclass:: simgrid.CancelException
+      .. autoclass:: simgrid.HostFailureException
+      .. autoclass:: simgrid.NetworkFailureException
+      .. autoclass:: simgrid.StorageFailureException
+      .. autoclass:: simgrid.TimeoutException
+      .. autoclass:: simgrid.VmFailureException
+
+      The following errors denote a problem in the SimGrid tool itself. Most of the time, you should let these
+      exception go, so that the simulation stops. But you may want to catch them, for example when you launch
+      simgrid from a python notebook and want to handle the problem accordingly.
+
+      .. autoclass:: simgrid.AssertionError
+
+   .. group-tab:: C
+
+      .. doxygenenum:: sg_error_t
+
+
 .. |hr| raw:: html
 
    <hr />
index 23a71ce..e580ea9 100644 (file)
@@ -3,14 +3,11 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+/* This file defines all possible exception that could occur in a SimGrid library. */
+
 #ifndef SIMGRID_EXCEPTIONS_HPP
 #define SIMGRID_EXCEPTIONS_HPP
 
-/** @file exception.hpp SimGrid-specific Exceptions
- *
- *  Defines all possible exception that could occur in a SimGrid library.
- */
-
 #include <xbt/backtrace.hpp>
 #include <xbt/ex.h>
 #include <xbt/string.hpp>
@@ -28,9 +25,7 @@ namespace xbt {
  *  Constitute the contextual information of where an exception was thrown
  *
  *  These tuples (__FILE__, __LINE__, __func__, backtrace, procname, pid)
- *  are best created with @ref XBT_THROW_POINT.
- *
- *  @ingroup XBT_ex
+ *  are best created with the macro XBT_THROW_POINT.
  */
 class ThrowPoint {
 public:
index 9dafa1c..96bcd6e 100644 (file)
@@ -316,13 +316,13 @@ typedef long long sg_offset_t;
 typedef long aid_t;
 
 typedef enum {
-  SG_OK,
-  SG_ERROR_CANCELED,
-  SG_ERROR_TIMEOUT,
-  SG_ERROR_HOST,
-  SG_ERROR_NETWORK,
-  SG_ERROR_STORAGE,
-  SG_ERROR_VM
+  SG_OK /** Code returned when no problem occured */,
+  SG_ERROR_CANCELED /** Code returned when something got canceled before completion */,
+  SG_ERROR_TIMEOUT /** Code returned when timeout elapsed */,
+  SG_ERROR_HOST /** Code returned when a host fails */,
+  SG_ERROR_NETWORK /** Code returned when a communication fails because of the network or because of the remote host */,
+  SG_ERROR_STORAGE /** Code returned when a storage fails */,
+  SG_ERROR_VM /** Code returned when a VM fails */
 } sg_error_t;
 
 XBT_PUBLIC int SMPI_is_inited();