move error model schema to error middleware