Skip to content

Commit

Permalink
Propagate XHR error to on_error in JS RestInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
Timoses committed Dec 26, 2016
1 parent 1554337 commit 195cce9
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions web/vibe/web/internal/rest/jsclient.d
Expand Up @@ -139,6 +139,9 @@ class JSRestClientSettings
fout.put("};\n");
}

// error handling
fout.put(`xhr.onerror = function (e) { if (on_error) on_error(e); else console.log("XHR request failed"); }`~"\n");

// header parameters
foreach (p; route.headerParameters)
fout.formattedWrite("xhr.setRequestHeader(%s, %s);\n", Json(p.fieldName), p.name);
Expand Down

0 comments on commit 195cce9

Please sign in to comment.