mstar.utils.client_errors

mstar.utils.client_errors#

Client-visible text for an exception raised while serving a request.

Functions

client_error_text(exc, what, *[, log, ...])

Return (text, error_id): what a client may see for exc.

scrub_paths(text)

Replace each absolute file path in text with its base name, and a directory path (one ending in "/") with <path>.

mstar.utils.client_errors.client_error_text(exc, what, *, log=logger, type_name=True, traceback=True)[source]#

Return (text, error_id): what a client may see for exc.

A ValueError or TypeError is a refusal raised on purpose, so it keeps its message (prefixed with the type name when type_name), with absolute paths cut to their base names. Anything else becomes internal error (error id <id>). Either way the full error and its traceback (left out when traceback is False, for an error already logged where it happened) go to log as <what> [error id <id>].

Parameters:
Return type:

tuple[str, str]

mstar.utils.client_errors.scrub_paths(text)[source]#

Replace each absolute file path in text with its base name, and a directory path (one ending in “/”) with <path>.

Parameters:

text (str)

Return type:

str