I use Javascript SDK to connect to Horizon. It works, but I also would like the specific error if it doesn't work. See my code below.

How can I access the specific code returned from horizon (e.g. 404)? Right now I only get "Error".

Thanks in advance.

// --- check if account is active
    .then(function (accountResult) 
    .catch(function (err) {
        document.getElementById("error").innerHTML = 'Account not valid or inactive1!';

1 Answer 1


The error object contains response field with HTTP response details from the server. You can refer to response.status to retrieve the status code.

if (err.response && err.response.status === 404) {
  console.error('Account does not exist.')
else {
  • 1
    Thanks, just what I was missing. I sent you some lumen on your expert donation address.
    – bluesky
    Mar 2, 2019 at 11:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.