Skip to content

Commit

Permalink
Merge pull request #38 from madnesspie/send-transaction-error-handling
Browse files Browse the repository at this point in the history
Adds error handling in rest api transaction creation
  • Loading branch information
madnesspie committed Jun 23, 2020
2 parents faa18a2 + 5cb4d96 commit dd02051
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion django_obm/__init__.py
Expand Up @@ -11,4 +11,4 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
__version__ = "0.3.2"
__version__ = "0.3.3"
8 changes: 6 additions & 2 deletions django_obm/serializers.py
Expand Up @@ -12,7 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from django.conf import settings
from rest_framework import serializers
from obm import exceptions as obm_exceptions
from rest_framework import exceptions, serializers

from django_obm import models

Expand Down Expand Up @@ -102,7 +103,10 @@ def create(self, validated_data):
"subtract_fee_from_amount"
)
tx = models.Transaction(**validated_data)
return tx.send(subtract_fee_from_amount=subtract_fee_from_amount)
try:
return tx.send(subtract_fee_from_amount=subtract_fee_from_amount)
except obm_exceptions.NodeError as exc:
raise exceptions.ValidationError(exc.args[0])


class AddressSerializer(serializers.ModelSerializer):
Expand Down

0 comments on commit dd02051

Please sign in to comment.