Add error handling to GlobalContext