Remove try-catch section.
Update encoder's API.
Catch exception in open/close.
Remove try-catch section.