add errors and status parsing middleware