src.core.error_responses module#

Marcus Error Response System.

Standardized error response formatting for different contexts: - MCP protocol responses - JSON API responses - User-friendly messages - Logging formats - Monitoring/alerting formats

class src.core.error_responses.ResponseFormat[source]#

Bases: Enum

Supported response formats.

MCP = 'mcp'#
JSON_API = 'json_api'#
USER_FRIENDLY = 'user_friendly'#
LOGGING = 'logging'#
MONITORING = 'monitoring'#
DEBUG = 'debug'#
class src.core.error_responses.ErrorResponseConfig[source]#

Bases: object

Configuration for error response formatting.

include_debug_info: bool = False#
include_stack_trace: bool = False#
include_system_context: bool = False#
include_remediation: bool = True#
max_message_length: int = 500#
sanitize_sensitive_data: bool = True#
custom_fields: Dict[str, Any]#
__init__(include_debug_info=False, include_stack_trace=False, include_system_context=False, include_remediation=True, max_message_length=500, sanitize_sensitive_data=True, custom_fields=<factory>)#
Parameters:
  • include_debug_info (bool)

  • include_stack_trace (bool)

  • include_system_context (bool)

  • include_remediation (bool)

  • max_message_length (int)

  • sanitize_sensitive_data (bool)

  • custom_fields (Dict[str, Any])

Return type:

None

class src.core.error_responses.ErrorResponseFormatter[source]#

Bases: object

Comprehensive error response formatter for Marcus errors.

Provides standardized formatting across different contexts while maintaining security and usability.

__init__(config=None)[source]#
Parameters:

config (ErrorResponseConfig | None)

format_error(error, format_type, additional_context=None)[source]#

Format error for specified response type.

Parameters:
Return type:

Dict[str, Any]

Returns:

Formatted error response dictionary

class src.core.error_responses.BatchErrorResponseFormatter[source]#

Bases: object

Formats responses for batch operations with multiple errors.

Provides summary views and detailed breakdowns of batch operation results.

__init__(formatter=None)[source]#
Parameters:

formatter (ErrorResponseFormatter | None)

format_batch_response(operation_name, errors, successes, total_operations, format_type=ResponseFormat.JSON_API)[source]#

Format response for batch operation with multiple errors.

Return type:

Dict[str, Any]

Parameters:
format_error_summary(errors)[source]#

Create a summary view of multiple errors.

Return type:

Dict[str, Any]

Parameters:

errors (List[MarcusBaseError])

src.core.error_responses.create_success_response(data=None, message='Operation completed successfully', metadata=None)[source]#

Create a standardized success response.

Return type:

Dict[str, Any]

Parameters:
src.core.error_responses.create_error_response(error, format_type=ResponseFormat.MCP, config=None, additional_context=None)[source]#

Create a standardized error response.

Return type:

Dict[str, Any]

Parameters:
src.core.error_responses.handle_mcp_tool_error(error, tool_name, arguments=None)[source]#

Handle errors in MCP tool calls.

Return type:

Dict[str, Any]

Parameters: