Gateway 502 error

"OriginStatus":502
How to retry use middlewares retry.
Can we specify an error code for retry.