Catch UnsupportedOperationException and handle it properly.