Updated error handling in plugin