If it appears on the return that the petitioner is in custody under a valid civil process of a court, the petitioner can be discharged only in the following cases:
- (1) if the jurisdiction of the court has been exceeded, either as to matter, place, sum, or person;
- (2) if, though the original imprisonment was lawful, yet, by some act, omission, or event which has taken place afterward, the person is entitled to be discharged;
- (3) if the process is defective in some matter of substance required by law, rendering it void;
- (4) if the process, though in proper form, has been issued in a case not allowed by law;
- (5) if the person having the custody of the petitioner under the process is not the person empowered by law to detain the petitioner; or
- (6) if the process is not authorized by a judgment or order of a court, or by a provision of law.