Add initial project configuration and setup for Reference Board Viewer application. Include EditorConfig for consistent coding styles, pre-commit hooks for linting and formatting, Docker Compose for local development with PostgreSQL and MinIO, and a Nix flake for development environment management. Establish CI/CD pipeline for automated testing and deployment.

This commit is contained in:
Danilo Reyes
2025-11-01 22:28:46 -06:00
parent 58f463867e
commit 1bc657e0fd
33 changed files with 1756 additions and 38 deletions

View File

@@ -0,0 +1,68 @@
"""Custom exception classes."""
from typing import Any
class WebRefException(Exception):
"""Base exception for all custom exceptions."""
def __init__(self, message: str, status_code: int = 500, details: dict[str, Any] | None = None):
self.message = message
self.status_code = status_code
self.details = details or {}
super().__init__(self.message)
class ValidationError(WebRefException):
"""Validation error."""
def __init__(self, message: str, details: dict[str, Any] | None = None):
super().__init__(message, status_code=422, details=details)
class AuthenticationError(WebRefException):
"""Authentication error."""
def __init__(self, message: str = "Authentication failed"):
super().__init__(message, status_code=401)
class AuthorizationError(WebRefException):
"""Authorization error."""
def __init__(self, message: str = "Insufficient permissions"):
super().__init__(message, status_code=403)
class NotFoundError(WebRefException):
"""Resource not found error."""
def __init__(self, resource: str, resource_id: str | None = None):
message = f"{resource} not found"
if resource_id:
message = f"{resource} with id {resource_id} not found"
super().__init__(message, status_code=404)
class ConflictError(WebRefException):
"""Resource conflict error."""
def __init__(self, message: str):
super().__init__(message, status_code=409)
class FileTooLargeError(WebRefException):
"""File size exceeds limit."""
def __init__(self, max_size: int):
message = f"File size exceeds maximum allowed size of {max_size} bytes"
super().__init__(message, status_code=413)
class UnsupportedFileTypeError(WebRefException):
"""Unsupported file type."""
def __init__(self, file_type: str, allowed_types: list[str]):
message = f"File type '{file_type}' not supported. Allowed types: {', '.join(allowed_types)}"
super().__init__(message, status_code=415)