Catch the exception when EC encoding or decoding