mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Return information about the exception
This commit is contained in:
parent
cc9e3b79b6
commit
d998b00592
@ -7,9 +7,16 @@ from flask import current_app, request, Blueprint
|
|||||||
from flask_restful import Resource, Api
|
from flask_restful import Resource, Api
|
||||||
|
|
||||||
from bigchaindb.common.exceptions import (
|
from bigchaindb.common.exceptions import (
|
||||||
ValidationError,
|
AmountError,
|
||||||
|
DoubleSpend,
|
||||||
|
InvalidHash,
|
||||||
InvalidSignature,
|
InvalidSignature,
|
||||||
SchemaValidationError,
|
SchemaValidationError,
|
||||||
|
OperationError,
|
||||||
|
TransactionDoesNotExist,
|
||||||
|
TransactionOwnerError,
|
||||||
|
TransactionNotInValidBlock,
|
||||||
|
ValidationError,
|
||||||
)
|
)
|
||||||
|
|
||||||
import bigchaindb
|
import bigchaindb
|
||||||
@ -108,16 +115,32 @@ class TransactionListApi(Resource):
|
|||||||
message='Invalid transaction schema: {}'.format(
|
message='Invalid transaction schema: {}'.format(
|
||||||
e.__cause__.message)
|
e.__cause__.message)
|
||||||
)
|
)
|
||||||
except (ValidationError, InvalidSignature):
|
except (ValidationError, InvalidSignature) as e:
|
||||||
return make_error(400, 'Invalid transaction')
|
return make_error(
|
||||||
|
400,
|
||||||
|
'Invalid transaction ({}): {}'.format(type(e).__name__, e)
|
||||||
|
)
|
||||||
|
|
||||||
with pool() as bigchain:
|
with pool() as bigchain:
|
||||||
if bigchain.is_valid_transaction(tx_obj):
|
try:
|
||||||
|
bigchain.validate_transaction(tx_obj)
|
||||||
|
except (ValueError,
|
||||||
|
OperationError,
|
||||||
|
TransactionDoesNotExist,
|
||||||
|
TransactionOwnerError,
|
||||||
|
DoubleSpend,
|
||||||
|
InvalidHash,
|
||||||
|
InvalidSignature,
|
||||||
|
TransactionNotInValidBlock,
|
||||||
|
AmountError) as e:
|
||||||
|
return make_error(
|
||||||
|
400,
|
||||||
|
'Invalid transaction ({}): {}'.format(type(e).__name__, e)
|
||||||
|
)
|
||||||
|
else:
|
||||||
rate = bigchaindb.config['statsd']['rate']
|
rate = bigchaindb.config['statsd']['rate']
|
||||||
with monitor.timer('write_transaction', rate=rate):
|
with monitor.timer('write_transaction', rate=rate):
|
||||||
bigchain.write_transaction(tx_obj)
|
bigchain.write_transaction(tx_obj)
|
||||||
else:
|
|
||||||
return make_error(400, 'Invalid transaction')
|
|
||||||
|
|
||||||
return tx
|
return tx
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user