add try/catch around code block