Flask backend with Vue 3 frontend for shop floor machine management. Includes database schema export for MySQL shopdb_flask database. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
55 lines
1.6 KiB
Python
55 lines
1.6 KiB
Python
"""Custom exceptions for ShopDB."""
|
|
|
|
|
|
class ShopDBException(Exception):
|
|
"""Base exception for ShopDB."""
|
|
|
|
def __init__(self, message: str, code: str = None, details: dict = None):
|
|
super().__init__(message)
|
|
self.message = message
|
|
self.code = code or 'SHOPDB_ERROR'
|
|
self.details = details or {}
|
|
|
|
|
|
class ValidationError(ShopDBException):
|
|
"""Validation error."""
|
|
|
|
def __init__(self, message: str, details: dict = None):
|
|
super().__init__(message, 'VALIDATION_ERROR', details)
|
|
|
|
|
|
class NotFoundError(ShopDBException):
|
|
"""Resource not found error."""
|
|
|
|
def __init__(self, resource: str, identifier):
|
|
message = f"{resource} with ID {identifier} not found"
|
|
super().__init__(message, 'NOT_FOUND', {'resource': resource, 'id': identifier})
|
|
|
|
|
|
class AuthenticationError(ShopDBException):
|
|
"""Authentication error."""
|
|
|
|
def __init__(self, message: str = "Authentication required"):
|
|
super().__init__(message, 'UNAUTHORIZED')
|
|
|
|
|
|
class AuthorizationError(ShopDBException):
|
|
"""Authorization error."""
|
|
|
|
def __init__(self, message: str = "Permission denied"):
|
|
super().__init__(message, 'FORBIDDEN')
|
|
|
|
|
|
class ConflictError(ShopDBException):
|
|
"""Conflict error (e.g., duplicate entry)."""
|
|
|
|
def __init__(self, message: str, details: dict = None):
|
|
super().__init__(message, 'CONFLICT', details)
|
|
|
|
|
|
class PluginError(ShopDBException):
|
|
"""Plugin-related error."""
|
|
|
|
def __init__(self, message: str, plugin_name: str = None):
|
|
super().__init__(message, 'PLUGIN_ERROR', {'plugin': plugin_name})
|