Errors come back as JSON, with a stable code to test in your code and a message to show or log:
details is there when there are several problems, one line each. Match on code, not on message: messages can be reworded.
An error never takes a request from your quota, nor a credit. When a search fails after it was counted, the request or the credits are given back before the answer is sent. One exception: when the search service did answer but brought nothing back — file_not_found, rejected, a source_error read from its reply, file_withheld — the search is free up to a daily allowance (see Limits); past it, it counts like any search. A service that is down, busy or too slow is always free, and so is an archive Orelys cannot check (archive_unchecked). X-Request-Charged always tells you.

Error codes

Your request

Your key and your plan

Limits

The search service