A poundmaster or an agent of the poundmaster who has custody of an animal under this chapter, is acting in an official capacity, and making a good-faith effort to comply with this chapter is immune from any civil or criminal liability for acts taken or omitted while attempting to comply with this chapter.