ats_utilities.exceptions.format_error module

Module

format_error.py

Copyright

Copyright (C) 2017 - 2026 Vladimir Roncevic <elektron.ronca@gmail.com> ats_utilities is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. ats_utilities is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Info

Error formatting functions.

ats_utilities.exceptions.format_error.format_error(exc: BaseException, prefix: str = '', debug: bool = False) str[source]

Format exception in a human-readable format.

Parameters:
  • exc (<BaseException>) – Exception to format.

  • prefix (<str>) – Prefix to add to the error message (unexpected exception).

  • debug (<bool> (default False)) – Whether to include debug information (location of the error in the code).

Returns:

Formatted error message.

Return type:

<str>

Exceptions:

None.

ats_utilities.exceptions.format_error.format_error_raw(exc: BaseException, debug: bool = False) str[source]

Format exception in a raw format (without prefix and without color codes).

Parameters:
  • exc (<BaseException>) – Exception to format.

  • debug (<bool> (default False)) – Whether to include debug information (location of the error in the code).

Returns:

Formatted error message.

Return type:

<str>

Exceptions:

None.

ats_utilities.exceptions.format_error.get_debug_info(exc: BaseException) str[source]

Get debug information about the exception.

Parameters:

exc (<BaseException>) – Exception to format.

Returns:

String with debug information.

Return type:

<str>

Exceptions:

None.