Compare commits

..

2 Commits

2 changed files with 13 additions and 9 deletions

View File

@ -35,12 +35,14 @@ class UploadForm(forms.Form):
).first() ).first()
if exist_annotation: if exist_annotation:
raise ValidationError("error: {} exist".format(file_name)) raise ValidationError("Error! Snapshot: {} already exists".format(file_name))
except ValueError: except json.JSONDecodeError:
raise ValidationError("Error in parsing JSON: {}. Check for file corruption.".format(file_name)) raise ValidationError("Error in parsing JSON: '{}'. Check for file integrity.".format(file_name))
except Exception: except ValidationError as e:
raise ValidationError("error in: {}".format(file_name)) raise e
except Exception as e:
raise ValidationError("Oops! Something went wrong in '{}': {}".format(file_name, str(e)))
self.evidences.append((file_name, file_json)) self.evidences.append((file_name, file_json))

View File

@ -53,13 +53,15 @@ class Command(BaseCommand):
with open(filepath, 'r') as file: with open(filepath, 'r') as file:
content = json.loads(file.read()) content = json.loads(file.read())
path_name = save_in_disk(content, self.user.institution.name) path_name = save_in_disk(content, self.user.institution.name)
self.snapshots.append((content, path_name)) self.snapshots.append((content, path_name))
except json.JSONDecodeError: except json.JSONDecodeError as e:
raise ValueError(f"Invalid JSON format in file {filepath}.") raise e
#or we cath'em all #or we cath'em all
except Exception as e: except Exception:
raise Exception(f"Oops! Something went wrong there") raise Exception(f"Oops! Something went wrong there")
def parsing(self): def parsing(self):
for s, p in self.snapshots: for s, p in self.snapshots:
try: try: