<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>Hi,</p>
<p>i'm doing the issue
<a class="moz-txt-link-freetext" href="https://github.com/kimchi-project/wok/issues/147">https://github.com/kimchi-project/wok/issues/147</a>, and got a
problem to deal with exceptions and Javascript. I got this code at
src/wok/root.py:<br>
<br>
# check for repetly<br>
l = len(self.failed_logins)<br>
if l >= 3:<br>
<br>
# verify if timeout is still valid<br>
last_try = self.failed_logins[l -1]<br>
if time.time() < (last_try["time"] +
self.fail_timeout):<br>
details = e = UnauthorizedError("WOKAUTH0004E",<br>
{"seconds":
self.fail_timeout})<br>
log_request(code, params, details, method, 403)<br>
import pdb;pdb.set_trace()<br>
raise cherrypy.HTTPError(403, e.message)<br>
return e.message<br>
<br>
<br>
So, it may raise an exception. I want to filter this exception at
UI. So i got this code:</p>
<p><br>
</p>
<p> wok.login(settings, function(data) {<br>
var query = window.location.search;<br>
var next = /.*next=(.*?)(&|$)/g.exec(query);<br>
<br>
if (next) {<br>
var next_url = decodeURIComponent(next[1]);<br>
}<br>
else {<br>
var lastPage = wok.cookie.get('lastPage');<br>
var next_url = lastPage ?
lastPage.replace(/\"/g,'') : "/";<br>
}<br>
wok.cookie.set('roles',JSON.stringify(data.roles));<br>
window.location.replace(window.location.pathname.replace(/\/+login.html/,
'') + next_url);<br>
}, function(jqXHR, textStatus, errorThrown) {<br>
if (jqXHR.responseText == "") {<br>
$("#messUserPass").hide();<br>
$("#missServer").show();<br>
} else {<br>
$("#missServer").hide();<br>
$("#messUserPass").show();<br>
}<br>
$("#messSession").hide();<br>
$("#logging").hide();<br>
$("#login").show();<br>
});<br>
<br>
The issue is:<br>
<br>
1) If i raise a cherrypy.HTTPError, i got a html error with the
message i created on the code. Here is an example
<a class="moz-txt-link-freetext" href="http://pastebin.com/AjkWwHBz">http://pastebin.com/AjkWwHBz</a>. The message is there, but i must
parse it.<br>
<br>
2) If i raise a InvalidOperation or other exception from wok, i
receive a error 500:<br>
</p>
<p> {<br>
"reason":"The server encountered an unexpected condition which
prevented it from fulfilling the request.",<br>
"code":"500 Internal Server Error" <br>
}<br>
<br>
I want to receive a json with the error, to make it to parse from
UI.<br>
<br>
</p>
<pre class="moz-signature" cols="72">--
Ramon Nunes Medeiros
Kimchi Developer
Linux Technology Center Brazil
IBM Systems & Technology Group
Phone : +55 19 2132 7878
<a class="moz-txt-link-abbreviated" href="mailto:ramonn@br.ibm.com">ramonn@br.ibm.com</a> </pre>
</body>
</html>