Apparently, holding a gun within the confines of your own home is punishable by death.
'The officer felt endangered' doesn't wash here, unless you accept that an officer can otherwise control the situation from start to finish, including inviting themselves over to your place.