Skip to content
Snippets Groups Projects
Commit f145336a authored by Simon Will's avatar Simon Will
Browse files

Improve handling of faulty MRLs

parent 56376c43
No related branches found
No related tags found
No related merge requests found
......@@ -20,7 +20,7 @@ def answer_query(mrl_query):
current_app.logger.info('Received py answering result')
return result
return {'error': 'Unknown MRL interpretation error'}
return {'type': 'error', 'error': 'Unknown MRL interpretation error'}
class AnswerResult(Result):
......
......@@ -137,13 +137,14 @@ class DiagnoseResult(Result):
tokens = nl.split(' ')
custom_suggestions = get_suggestions(tokens)
return cls(success=True, nl=nl, mrl=mrl, taginfo=taginfo,
tf_idf_scores=tf_idf_scores,
return cls(success=success, error=error, nl=nl, mrl=mrl,
taginfo=taginfo, tf_idf_scores=tf_idf_scores,
custom_suggestions=custom_suggestions)
def to_dict(self):
return {
'nl': self.nl, 'mrl': self.mrl, 'taginfo': self.taginfo,
'tf_idf_scores': self.tf_idf_scores,
'custom_suggestions': self.custom_suggestions
'custom_suggestions': self.custom_suggestions,
'error': self.error
}
......@@ -149,7 +149,12 @@ window.addEventListener('load', function() {
callback(diagnoseResult);
},
function(xhr) {
messagesBlock.addMessage('Diagnosing failed.', true);
const diagnoseResult = JSON.parse(xhr.responseText);
let msg = 'Diagnosing failed.';
if (diagnoseResult.error) {
msg += ' ' + diagnoseResult.error;
}
messagesBlock.addMessage(msg, true);
},
null,
formData
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment