- Show custom field values in asset list, dashboard and list Excel export - New status flag to exclude assets (e.g. scrapped) from MeshCentral sync - Require a secure SESSION_SECRET with a readable startup message - Add SESSION_COOKIE_SECURE and refresh session permissions per request - Translate HTTP errors and remaining fixed UI texts Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
24 lines
818 B
Python
24 lines
818 B
Python
from typing import Any
|
|
|
|
from fastapi import HTTPException
|
|
|
|
|
|
class TranslatedHTTPException(HTTPException):
|
|
"""HTTP error carrying a translation key instead of fixed text.
|
|
|
|
The application exception handler translates the key into the language of
|
|
the current user. ``detail`` holds the English default so handlers without
|
|
translation support (for example the callback-only service) still return
|
|
readable text.
|
|
"""
|
|
|
|
def __init__(self, status_code: int, key: str, default: str, **values: Any) -> None:
|
|
try:
|
|
detail = default.format(**values)
|
|
except (KeyError, ValueError):
|
|
detail = default
|
|
super().__init__(status_code, detail)
|
|
self.translation_key = key
|
|
self.translation_default = default
|
|
self.translation_values = values
|