Fix exception handling during context registration