(a) Every person who has been, in good faith, served with a subpoena to attend as witness before a court, judge, commissioner, referee, or other officer, is exonerated from arrest or service of summons in a civil case while going to the place of attendance, necessarily remaining there, and returning therefrom.
(b) The arrest of or service of a summons upon a witness contrary to this section is void, and when wilfully made is a contempt of court; and the officer making it is responsible to the witness arrested or served for double the amount of damages which may be assessed against him therefor, and is also liable to an action at the suit of the party serving the witness with the subpoena for the damages sustained by him in consequence of the arrest or service.
(c) The court, judge, or officer before whom the attendance of the witness is required may discharge a witness from an arrest made in violation of this section.