fix: improved error handling