Catching errors with system()

I’m using system() to use curl. It works well but sometimes the wifi drops and the curl throws an error and the OF app crashes. Can I try/catch this like I would haphazardly in Java? Or any other ideas?