mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-08-04 13:47:37 +02:00
Improve config validation error messages (#11292)
This commit is contained in:
parent
3ed89ec042
commit
2be15b6c01
@ -16,6 +16,7 @@ import psutil
|
||||
from peewee_migrate import Router
|
||||
from playhouse.sqlite_ext import SqliteExtDatabase
|
||||
from playhouse.sqliteq import SqliteQueueDatabase
|
||||
from pydantic import ValidationError
|
||||
|
||||
from frigate.api.app import create_app
|
||||
from frigate.comms.config_updater import ConfigPublisher
|
||||
@ -611,6 +612,11 @@ class FrigateApp:
|
||||
print("*************************************************************")
|
||||
print("*** Config Validation Errors ***")
|
||||
print("*************************************************************")
|
||||
if isinstance(e, ValidationError):
|
||||
for error in e.errors():
|
||||
location = ".".join(str(item) for item in error["loc"])
|
||||
print(f"{location}: {error['msg']}")
|
||||
else:
|
||||
print(e)
|
||||
print(traceback.format_exc())
|
||||
print("*************************************************************")
|
||||
|
@ -555,6 +555,7 @@ class ZoneConfig(BaseModel):
|
||||
# old native resolution coordinates
|
||||
if isinstance(coordinates, list):
|
||||
explicit = any(p.split(",")[0] > "1.0" for p in coordinates)
|
||||
try:
|
||||
self._contour = np.array(
|
||||
[
|
||||
(
|
||||
@ -568,6 +569,10 @@ class ZoneConfig(BaseModel):
|
||||
for p in coordinates
|
||||
]
|
||||
)
|
||||
except ValueError:
|
||||
raise ValueError(
|
||||
f"Invalid coordinates found in configuration file. Coordinates must be relative (between 0-1): {coordinates}"
|
||||
)
|
||||
|
||||
if explicit:
|
||||
self.coordinates = ",".join(
|
||||
@ -579,6 +584,7 @@ class ZoneConfig(BaseModel):
|
||||
elif isinstance(coordinates, str):
|
||||
points = coordinates.split(",")
|
||||
explicit = any(p > "1.0" for p in points)
|
||||
try:
|
||||
self._contour = np.array(
|
||||
[
|
||||
(
|
||||
@ -592,6 +598,10 @@ class ZoneConfig(BaseModel):
|
||||
for i in range(0, len(points), 2)
|
||||
]
|
||||
)
|
||||
except ValueError:
|
||||
raise ValueError(
|
||||
f"Invalid coordinates found in configuration file. Coordinates must be relative (between 0-1): {coordinates}"
|
||||
)
|
||||
|
||||
if explicit:
|
||||
self.coordinates = ",".join(
|
||||
|
Loading…
Reference in New Issue
Block a user