We handle errors with the UnicatError
exception.
from unicat import Unicat, UnicatError
from config import PROJECT_GID, SECRET_API_KEY, LOCAL_ASSET_FOLDER
unicat = Unicat("https://unicat.app", PROJECT_GID, SECRET_API_KEY, LOCAL_ASSET_FOLDER)
if not unicat.connect():
raise Exception("Invalid connection settings")
...
try:
unicat.mutate.update_record(record, {language: fields_data})
except UnicatError as e:
print(e, e.code, e.message, e.info)
The .code
, .message
, and .info
properties match the API error result, see The basics for sending and retrieving data.