added some javadoc
avoid catching throwable
new exception for encoding problems