From 396df4f1cae880774fda4f4fe8c38a34793c86c6 Mon Sep 17 00:00:00 2001 From: Carey Metcalfe Date: Sat, 6 Oct 2018 00:25:47 -0400 Subject: [PATCH] Stringify Exceptions when creating SubsonicAPIExceptions from them This prevents a `TypeError` from being raised when the `SubsonicAPIException` is serialized to JSON in preparation for being returned to the client. --- supysonic/api/errors.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/supysonic/api/errors.py b/supysonic/api/errors.py index 818ec39..6d03629 100644 --- a/supysonic/api/errors.py +++ b/supysonic/api/errors.py @@ -18,7 +18,7 @@ from .exceptions import GenericError, MissingParameter, NotFound, ServerError @api.errorhandler(ValueError) def value_error(e): rollback() - return GenericError(e) + return GenericError("{0.__class__.__name__}: {0}".format(e)) @api.errorhandler(BadRequestKeyError) def key_error(e): @@ -33,7 +33,7 @@ def not_found(e): @api.errorhandler(500) def generic_error(e): # pragma: nocover rollback() - return ServerError(e) + return ServerError("{0.__class__.__name__}: {0}".format(e)) #@api.errorhandler(404) @api.route('/', methods = [ 'GET', 'POST' ]) # blueprint 404 workaround