Compare commits

..

No commits in common. "79951f3c4b4054dfb6b5a2583778568147fe7cd9" and "3faa98a60e4f136254d89793af76da4464a87536" have entirely different histories.

2 changed files with 9 additions and 13 deletions

View File

@ -35,14 +35,12 @@ class UploadForm(forms.Form):
).first() ).first()
if exist_annotation: if exist_annotation:
raise ValidationError("Error! Snapshot: {} already exists".format(file_name)) raise ValidationError("error: {} exist".format(file_name))
except json.JSONDecodeError: except ValueError:
raise ValidationError("Error in parsing JSON: '{}'. Check for file integrity.".format(file_name)) raise ValidationError("Error in parsing JSON: {}. Check for file corruption.".format(file_name))
except ValidationError as e: except Exception:
raise e raise ValidationError("error in: {}".format(file_name))
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,17 +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 as e: except json.JSONDecodeError:
raise e raise ValueError(f"Invalid JSON format in file {filepath}.")
#or we cath'em all #or we cath'em all
except Exception: except Exception as e:
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:
self.devices.append(Build(s, self.user)) self.devices.append(Build(s, self.user))
move_json(p, self.user.institution.name) move_json(p, self.user.institution.name)