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:
EnumSupported 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:
objectConfiguration for error response formatting.
- __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>)#
- class src.core.error_responses.ErrorResponseFormatter[source]#
Bases:
objectComprehensive 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:
error (
Union[MarcusBaseError,Exception]) – The error to format.format_type (
ResponseFormat) – Target format for the response.additional_context (
Optional[Dict[str,Any]]) – Additional context to include.
- Return type:
- Returns:
Formatted error response dictionary
- class src.core.error_responses.BatchErrorResponseFormatter[source]#
Bases:
objectFormats 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:
- Parameters:
operation_name (str)
errors (List[MarcusBaseError])
successes (int)
total_operations (int)
format_type (ResponseFormat)
- src.core.error_responses.create_success_response(data=None, message='Operation completed successfully', metadata=None)[source]#
Create a standardized success response.
- 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:
- Parameters:
error (MarcusBaseError | Exception)
format_type (ResponseFormat)
config (ErrorResponseConfig | None)