my test sends a request and validate code status to be one of 200 or 204.
When it fails the code status could anything like 400,404,500,504…etc
And there will be an error message too.
How can i catch the error message with its code status?
In my case the problem is:
when the request pass the response is empty but i receive a status code 204 or 200.
When the request fails the response has html format if status code is 503
If status is 404 the reponse is in json
So depending the type of errors the reponse body is not the same.
I dont know all type of errors the request could return.
So i just want the tests get 200 or 204 when it passes.
and when the test fails i need to catch all errors and print it in console.log()