Merge branch 'fix/broken-test-master' into 'master'
Improve the validation messages for data from the calculator See merge request cara/cara!44
This commit is contained in:
commit
e3799d02d7
2 changed files with 3 additions and 1 deletions
|
|
@ -30,7 +30,7 @@ class ConcentrationModel(RequestHandler):
|
|||
except Exception as err:
|
||||
if DEBUG:
|
||||
import traceback
|
||||
traceback.print_last()
|
||||
print(traceback.format_exc())
|
||||
response_json = {'code': 400, 'error': f'Your request was invalid {err}'}
|
||||
self.set_status(400)
|
||||
self.finish(json.dumps(response_json))
|
||||
|
|
|
|||
|
|
@ -56,6 +56,8 @@ class FormData:
|
|||
('volume_type', VOLUME_TYPES),
|
||||
('windows_open', WINDOWS_OPEN)]
|
||||
for key, valid_set in validation_tuples:
|
||||
if key not in form_data:
|
||||
raise ValueError(f"Missing key {key}")
|
||||
if form_data[key] not in valid_set:
|
||||
raise ValueError(f"{form_data[key]} is not a valid value for {key}")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue