Skip to content

Commit ba20fb0

Browse files
rowan04tofu-rocketry
authored andcommitted
Improve loader check exception handling, using specific exceptions
- also fixes validator bug which would prevent v0.4 records from getting a formatted output
1 parent c75bb55 commit ba20fb0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

monitoring/validator/views.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
from django.views.decorators.http import require_http_methods
33

44
# Apel loader and record-checking class imports
5-
from apel.db.loader.loader import Loader
5+
from apel.db import ApelDbException
6+
from apel.db.loader.loader import Loader, LoaderException
67
from apel.db.loader.record_factory import RecordFactory, RecordFactoryException
78
from apel.db.records.record import InvalidRecordException
89

@@ -103,7 +104,7 @@ def validate(record: str, record_type: str) -> str:
103104
record_class = record_map[record_type]
104105
result = recordFactory._create_record_objects(record, record_class)
105106

106-
if "Record object at" in str(result):
107+
if "object at" in str(result):
107108
return "Record(s) valid!"
108109

109110
return str(result)
@@ -148,5 +149,5 @@ def load(record: str) -> str:
148149

149150
return("Record(s) will load successfully!")
150151

151-
except Exception as e:
152+
except (ApelDbException, InvalidRecordException, LoaderException, RecordFactoryException) as e:
152153
return str(e)

0 commit comments

Comments
 (0)