From 666e8973e3aef5c501483e75bd517633411614c0 Mon Sep 17 00:00:00 2001 From: mancini <mancini@astron.nl> Date: Thu, 3 Jun 2021 16:10:17 +0200 Subject: [PATCH] Throws the right exception if id already exists --- lib/query.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/query.py b/lib/query.py index d0ffbee..d8b4718 100644 --- a/lib/query.py +++ b/lib/query.py @@ -23,6 +23,8 @@ class LTAClientExistsAlready(Exception): class LTAClientError(Exception): pass +class LTAIDAlreadyExists(Exception): + pass def lta_on_error_print(func): def wrapper(*args, **kwargs): @@ -147,7 +149,7 @@ def create_unique_id(source, userlabel=None): if not response.get("result") == "ok": raise Exception('An identifier for this userlabel could not be created -> ' + str(response.get("error"))) if not response.get("is_new"): - raise Exception('An identifier for this userlabel already exists -> ' + str(userlabel)) + raise LTAIDAlreadyExists('An identifier for this userlabel already exists -> ' + str(userlabel)) return response.get('id') -- GitLab