add Exceptions in decode and encode