facebookarchive / swift

An annotation-based Java library for creating Thrift serializable types and services.
Apache License 2.0
900 stars 297 forks source link

Add declared/undeclared exception hooks to Thrift event handlers #282

Closed andrewcox closed 8 years ago

alandau commented 8 years ago

lgtm

dain commented 8 years ago

I would follow the JAX-RS model where you have exception handlers that can rewrite the response. This allows you to catch exceptions that you can't annotate, and rewrite them into a proper error code.

andrewcox commented 8 years ago

Interesting. I've thought about this for the client calls for the srproxy client, to make it simpler to translate TApplicationException w/ specific codes into TTransportException.

On the server side I'm not convinced because you have limited options for what you'd be allowed to translate the excpetion to (you can only translate to the common TApplicationException, or else some other exception declared on @ThriftMethod annotations as throwable from that method. Anything else, and we wouldn't be able to serialize it.