[api] return exception in json format, pretty pring in debug, reduce code dups.
Merge pull request #22 from Payum/api-add-generic-api-listeners

[api] return exception in json format, pretty pring in debug, reduce cod...