feat: add forgejo_error_reporter plugin for automatic error reporting to Forgejo issues

This commit is contained in:
Agent Zero
2026-07-26 12:49:39 +02:00
parent b9d05e2198
commit c3e41906bf
16 changed files with 608 additions and 14 deletions
+19
View File
@@ -0,0 +1,19 @@
"""Standardized error codes for consistent frontend handling."""
ERROR_CODES = {
'not_found': {'status': 404, 'message': 'Resource not found'},
'permission_denied': {'status': 403, 'message': 'Permission denied'},
'validation_error': {'status': 422, 'message': 'Validation failed'},
'rate_limited': {'status': 429, 'message': 'Too many requests'},
'internal_error': {'status': 500, 'message': 'Internal server error'},
'service_unavailable': {'status': 503, 'message': 'Service temporarily unavailable'},
}
class ApiError(Exception):
def __init__(self, code: str, detail: str = None, field: str = None, status: int = None):
self.code = code
self.detail = detail or ERROR_CODES.get(code, {}).get('message', 'Unknown error')
self.field = field
self.status = status or ERROR_CODES.get(code, {}).get('status', 500)
super().__init__(self.detail)