Skip to content

Commit 38546fe

Browse files
authored
add error handling for not valid json schema data (#218)
fix(smartdatamodels): add error handling for not valid data models
1 parent 729f273 commit 38546fe

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

app/Entirety/entities/views.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,18 @@ def get_context_data(self, **kwargs):
190190
def post(self, request, *args, **kwargs):
191191
# load data model
192192
if "load" in self.request.POST:
193+
context = super(Create, self).get_context_data(**kwargs)
193194
if self.request.POST.get("data_model") == "..":
194195
entity_json = {}
195196
else:
196-
entity_json = parse_entity(self.request.POST.get("data_model"))
197-
context = super(Create, self).get_context_data(**kwargs)
197+
try:
198+
entity_json = parse_entity(self.request.POST.get("data_model"))
199+
# except NotImplementedError as e:
200+
except KeyError as e:
201+
messages.error(
202+
self.request, f"Error parsing data model: missing key {e}"
203+
)
204+
entity_json = {}
198205
basic_info = EntityForm(
199206
self.project,
200207
initial={"id": entity_json.get("id"), "type": entity_json.get("type")},

0 commit comments

Comments
 (0)