Add error handling for unsupported label uploading to frigate+ (#9775)

This commit is contained in:
Maximo Guk
2024-02-10 15:35:17 -04:00
committed by GitHub
parent 91cdf64602
commit 86341c3172
3 changed files with 87 additions and 21 deletions

View File

@@ -171,6 +171,17 @@ class PlusApi:
)
if not r.ok:
try:
error_response = r.json()
errors = error_response.get("errors", [])
for error in errors:
if (
error.get("param") == "label"
and error.get("type") == "invalid_enum_value"
):
raise ValueError(f"Unsupported label value provided: {label}")
except ValueError as e:
raise e
raise Exception(r.text)
def add_annotation(
@@ -193,6 +204,17 @@ class PlusApi:
)
if not r.ok:
try:
error_response = r.json()
errors = error_response.get("errors", [])
for error in errors:
if (
error.get("param") == "label"
and error.get("type") == "invalid_enum_value"
):
raise ValueError(f"Unsupported label value provided: {label}")
except ValueError as e:
raise e
raise Exception(r.text)
def get_model_download_url(