fix: enhance error handling