forked from Github/frigate
Add error handling for unsupported label uploading to frigate+ (#9775)
This commit is contained in:
@@ -275,6 +275,13 @@ def send_to_plus(id):
|
||||
box,
|
||||
event.label,
|
||||
)
|
||||
except ValueError:
|
||||
message = "Error uploading annotation, unsupported label provided."
|
||||
logger.error(message)
|
||||
return make_response(
|
||||
jsonify({"success": False, "message": message}),
|
||||
400,
|
||||
)
|
||||
except Exception as ex:
|
||||
logger.exception(ex)
|
||||
return make_response(
|
||||
@@ -346,6 +353,13 @@ def false_positive(id):
|
||||
event.model_type,
|
||||
event.detector_type,
|
||||
)
|
||||
except ValueError:
|
||||
message = "Error uploading false positive, unsupported label provided."
|
||||
logger.error(message)
|
||||
return make_response(
|
||||
jsonify({"success": False, "message": message}),
|
||||
400,
|
||||
)
|
||||
except Exception as ex:
|
||||
logger.exception(ex)
|
||||
return make_response(
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user