return validating error
This commit is contained in:
parent
705b86cb99
commit
919d4a43d3
|
@ -2,6 +2,7 @@ import os
|
||||||
import time
|
import time
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from flask import current_app as app, request, g, Response
|
from flask import current_app as app, request, g, Response
|
||||||
|
from marshmallow import ValidationError
|
||||||
from teal.resource import View
|
from teal.resource import View
|
||||||
|
|
||||||
from ereuse_devicehub.db import db
|
from ereuse_devicehub.db import db
|
||||||
|
@ -19,7 +20,11 @@ class TradeDocumentView(View):
|
||||||
def post(self):
|
def post(self):
|
||||||
"""Add one document."""
|
"""Add one document."""
|
||||||
|
|
||||||
|
try:
|
||||||
data = request.get_json(validate=True)
|
data = request.get_json(validate=True)
|
||||||
|
except ValueError as err:
|
||||||
|
raise ValidationError(err)
|
||||||
|
|
||||||
hash3 = data['file_hash']
|
hash3 = data['file_hash']
|
||||||
db_hash = ReportHash(hash3=hash3)
|
db_hash = ReportHash(hash3=hash3)
|
||||||
db.session.add(db_hash)
|
db.session.add(db_hash)
|
||||||
|
|
Reference in a new issue