Add nil check before dereference of `error`.