The officer was trying to retrieve a gun from a storm drain when it went off at least once, police said.