comparison Sphinx/source/plugins/python.rst @ 747:56d48f6e52cc

catching exceptions in python plugins
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 09 Aug 2021 18:29:38 +0200
parents 97e6a0431c5e
children a296fe06fd86
comparison
equal deleted inserted replaced
746:b2b1ba11faaa 747:56d48f6e52cc
693 incoming C-STORE request, it makes a POST call to the URI 693 incoming C-STORE request, it makes a POST call to the URI
694 ``/instances`` in the REST API of Orthanc in order to store the 694 ``/instances`` in the REST API of Orthanc in order to store the
695 embedded DICOM dataset into Orthanc. Obviously, one can build more 695 embedded DICOM dataset into Orthanc. Obviously, one can build more
696 complex DICOM servers by handling more messages than C-STORE alone. 696 complex DICOM servers by handling more messages than C-STORE alone.
697 697
698 698
699 .. _python_exception:
700
701 Catching exceptions
702 ...................
703
704 Starting with release 3.3 of the Python plugin, the plugin generates a
705 Python exception derived from class ``orthanc.OrthancException`` if an
706 error is encountered. This exception contains a tuple that provides
707 the error code and its textual description.
708
709 In releases <= 3.2, the Python plugin raised the `built-in exception
710 <https://docs.python.org/3/library/exceptions.html>`__ ``ValueError``.
711
712 Here is an example showing how to catch exceptions:
713
714 .. literalinclude:: python/exception.py
715 :language: python
716
699 717
700 Performance and concurrency 718 Performance and concurrency
701 --------------------------- 719 ---------------------------
702 720
703 **Important:** This section only applies to UNIX-like systems. The 721 **Important:** This section only applies to UNIX-like systems. The