Skip to content

Commit

Permalink
doc(CommandError): an initial write-up of the class documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
mih committed Jun 6, 2024
1 parent 150c0e3 commit f960fae
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
16 changes: 16 additions & 0 deletions datasalad/runners/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""Execution of subprocesses
This module provides relevant components for subprocess execution.
Execution errors are communicated with the
:class:`~datasalad.runners.CommandError` exception.
.. currentmodule:: datasalad.runners
.. autosummary::
:toctree: generated
CommandError
"""

__all__ = ['CommandError']

from .exception import CommandError
19 changes: 15 additions & 4 deletions datasalad/runners/exception.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
"""Exception raise on a failed runner command execution
"""Exception raised on a failed command execution
"""
from __future__ import annotations

import os


class CommandError(RuntimeError):
"""Thrown if a command call fails.
"""Raised when a subprocess execution fails (non-zero exit)
Note: Subclasses should override `to_str` rather than `__str__` because
`to_str` is called directly in datalad.cli.main.
Key class attributes are aligned with the ``CalledProcessError`` exception
of the ``subprocess`` module of the Python standard library. However,
this class is not a subclass of ``CalledProcessError``, but a subclass
of ``RuntimeError``.
At minimum, the command with the failed execution must be provided
as an argument. A number of additional information items can be provided
in addition to enable more comprehensive reporting on execution failures.
As an addition to the ``CalledProcessError`` arguments, a ``msg`` parameter
is supported which can be used to include contextual information on the
command execution, for example why a command execution was attempted, or
under which particular circumstances.
"""

def __init__(
Expand Down
10 changes: 9 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,15 @@ Welcome to datasalad's documentation!
:maxdepth: 2
:caption: Contents:

Here be dragons!

Provided functionality
----------------------

.. currentmodule:: datasalad
.. autosummary::
:toctree: generated

runners


Indices and tables
Expand Down

0 comments on commit f960fae

Please sign in to comment.