Handing edge cases
Since the API is often called at critical points in an application (i.e. user registration, during a transaction), it's important to write failsafe code.
There are some things you need to consider:
- Handle HTTP errors such as connection problems, or a non-
200
status code, without blocking your application flow. - Always set a sensible HTTP timeout (15 seconds is usually a good start).
- If you need to rely on lookup data, make sure that the the
success
property istrue
. For example, if you need to use the phone lookup data, first check thatphone.success
istrue
.
tip
It's usually best to log errors but not block your application flow. If you're using Hitprobe to screen new user registrations, it's often preferable to allow the sign up to proceed even if the API call to Hitprobe fails. This is what is meant by failsafe.
You can find more detailed information about timeouts and error handling in the reference section.