Improve error handling for "import/word-arc" endpoint
A) Currently arc api returns 500 error to the end user when communication with extyles endpoint fails or api auth on extyles side fails. We should log the error (received from extyles) in the logs and return appropriate error code with a more meaningful message to the end user.
For eg. when user passes incorrect "pressroom-extylesarc-secret", api returns 500 error with the message
{error: "Request failed with status code 400"}
It should instead:
- return 400 response code
- log the error returned from extyles
{"status":"error","message":"Error: api_xyz is empty."}
- return more meaningful message to the user. For instance, in this case it should say that there was an error processing the request and passed secret is invalid.
B) Validation of arc credentials can also be made better. When invalid secret is passed and the resulting pass/api_key is empty, we can return the error to the end user directly, rather than calling extyles with invalid creds.
C) If one of the subsequent calls fails [let's say network error while downloading the generated XML (get_results api)], user currently gets following error message in api response
error: "ENOENT: no such file or directory, open '/private/var/folders/dd/q49hhz_10z5bqxm0000gn/T/2a4be5636f315e660d/manuscript.XML'"
- We should prevent giving out file paths in api response
- Give a more meaningful message as the above error message does not give any indication to the end user as to what went wrong.