Skip to content

Commit 5e6e78a

Browse files
[PLT-821][PLT-822] Throw user readable errors when creating a custom embedding with an existing name or too few dimensions.
1 parent 7fac32f commit 5e6e78a

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

libs/labelbox/src/labelbox/adv_client.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import logging
44
from typing import Dict, Any, Optional, List, Callable
55
from urllib.parse import urlparse
6+
from labelbox.exceptions import ADVError
67

78
import requests
89
from requests import Session, Response
@@ -59,7 +60,12 @@ def _request(self,
5960
url,
6061
data=requests_data,
6162
headers=headers)
62-
response.raise_for_status()
63+
if response.status_code != requests.codes.ok:
64+
message = response.json().get('message')
65+
if message:
66+
raise ADVError(message)
67+
else:
68+
response.raise_for_status()
6369
return response.json()
6470

6571
def _send_ndjson(self,

libs/labelbox/src/labelbox/exceptions.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ def __init__(self, message, cause=None):
1515
def __str__(self):
1616
return self.message + str(self.args)
1717

18+
class ADVError(LabelboxError):
19+
"""Raised when ADV service returns an error for a REST call"""
20+
pass
1821

1922
class AuthenticationError(LabelboxError):
2023
"""Raised when an API key fails authentication."""

0 commit comments

Comments
 (0)