Handle potential errors