mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-30 12:33:01 +00:00
Compare commits
4 Commits
fix/no-def
...
7f95c76c18
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7f95c76c18 | ||
|
|
bd124596be | ||
|
|
65d2ff3751 | ||
|
|
a0567a66cc |
@@ -214,19 +214,47 @@ class WebInterfaceError:
|
|||||||
|
|
||||||
return cls(
|
return cls(
|
||||||
error_code=error_code,
|
error_code=error_code,
|
||||||
message=str(exception),
|
message=cls._safe_message(error_code),
|
||||||
details=cls._get_exception_details(exception),
|
details=cls._get_exception_details(exception),
|
||||||
context=error_context,
|
context=error_context,
|
||||||
original_error=exception
|
original_error=exception
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _safe_message(cls, error_code: ErrorCode) -> str:
|
||||||
|
"""Get a safe, user-facing message for an error code."""
|
||||||
|
messages = {
|
||||||
|
ErrorCode.CONFIG_SAVE_FAILED: "Failed to save configuration",
|
||||||
|
ErrorCode.CONFIG_LOAD_FAILED: "Failed to load configuration",
|
||||||
|
ErrorCode.CONFIG_VALIDATION_FAILED: "Configuration validation failed",
|
||||||
|
ErrorCode.CONFIG_ROLLBACK_FAILED: "Failed to rollback configuration",
|
||||||
|
ErrorCode.PLUGIN_NOT_FOUND: "Plugin not found",
|
||||||
|
ErrorCode.PLUGIN_INSTALL_FAILED: "Failed to install plugin",
|
||||||
|
ErrorCode.PLUGIN_UPDATE_FAILED: "Failed to update plugin",
|
||||||
|
ErrorCode.PLUGIN_UNINSTALL_FAILED: "Failed to uninstall plugin",
|
||||||
|
ErrorCode.PLUGIN_LOAD_FAILED: "Failed to load plugin",
|
||||||
|
ErrorCode.PLUGIN_OPERATION_CONFLICT: "A plugin operation is already in progress",
|
||||||
|
ErrorCode.VALIDATION_ERROR: "Validation error",
|
||||||
|
ErrorCode.SCHEMA_VALIDATION_FAILED: "Schema validation failed",
|
||||||
|
ErrorCode.INVALID_INPUT: "Invalid input",
|
||||||
|
ErrorCode.NETWORK_ERROR: "Network error",
|
||||||
|
ErrorCode.API_ERROR: "API error",
|
||||||
|
ErrorCode.TIMEOUT: "Operation timed out",
|
||||||
|
ErrorCode.PERMISSION_DENIED: "Permission denied",
|
||||||
|
ErrorCode.FILE_PERMISSION_ERROR: "File permission error",
|
||||||
|
ErrorCode.SYSTEM_ERROR: "A system error occurred",
|
||||||
|
ErrorCode.SERVICE_UNAVAILABLE: "Service unavailable",
|
||||||
|
ErrorCode.UNKNOWN_ERROR: "An unexpected error occurred",
|
||||||
|
}
|
||||||
|
return messages.get(error_code, "An unexpected error occurred")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _infer_error_code(cls, exception: Exception) -> ErrorCode:
|
def _infer_error_code(cls, exception: Exception) -> ErrorCode:
|
||||||
"""Infer error code from exception type."""
|
"""Infer error code from exception type."""
|
||||||
exception_name = type(exception).__name__
|
exception_name = type(exception).__name__
|
||||||
|
|
||||||
if "Config" in exception_name:
|
if "Config" in exception_name:
|
||||||
return ErrorCode.CONFIG_SAVE_FAILED
|
return ErrorCode.CONFIG_LOAD_FAILED
|
||||||
elif "Plugin" in exception_name:
|
elif "Plugin" in exception_name:
|
||||||
return ErrorCode.PLUGIN_LOAD_FAILED
|
return ErrorCode.PLUGIN_LOAD_FAILED
|
||||||
elif "Permission" in exception_name or "Access" in exception_name:
|
elif "Permission" in exception_name or "Access" in exception_name:
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ from datetime import datetime, timedelta
|
|||||||
sys.path.insert(0, str(Path(__file__).parent.parent))
|
sys.path.insert(0, str(Path(__file__).parent.parent))
|
||||||
|
|
||||||
from src.config_manager import ConfigManager
|
from src.config_manager import ConfigManager
|
||||||
|
from src.exceptions import ConfigError
|
||||||
from src.plugin_system.plugin_manager import PluginManager
|
from src.plugin_system.plugin_manager import PluginManager
|
||||||
from src.plugin_system.store_manager import PluginStoreManager
|
from src.plugin_system.store_manager import PluginStoreManager
|
||||||
from src.plugin_system.saved_repositories import SavedRepositoriesManager
|
from src.plugin_system.saved_repositories import SavedRepositoriesManager
|
||||||
@@ -492,7 +493,7 @@ def display_preview_generator():
|
|||||||
parallel = main_config.get('display', {}).get('hardware', {}).get('parallel', 1)
|
parallel = main_config.get('display', {}).get('hardware', {}).get('parallel', 1)
|
||||||
width = cols * chain_length
|
width = cols * chain_length
|
||||||
height = rows * parallel
|
height = rows * parallel
|
||||||
except (KeyError, TypeError, ValueError):
|
except (KeyError, TypeError, ValueError, ConfigError):
|
||||||
width = 128
|
width = 128
|
||||||
height = 64
|
height = 64
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user