Reuse the stemweb dialog for queries. Fixes #44
[scpubgit/stemmaweb.git] / lib / stemmaweb / Controller / Stemweb.pm
index ad90815..42126ec 100644 (file)
@@ -214,11 +214,13 @@ sub _process_stemweb_result {
                        }
                        $c->stash->{'result'} = { status => 'notfound' };
                }
-       } elsif( $answer->{status} == -1 ) {
+       } elsif( $answer->{status} == 1 ) {
                $c->stash->{'result'} = { 'status' => 'running' };
        } else {
-               return _json_error( $c, 500,
-                       "Stemweb failure not handled: " . $answer->{result} );
+               # Failure. Clear the job ID so that the user can try again.
+               $tradition->_clear_stemweb_jobid;
+               $m->save( $tradition );
+               $c->stash->{'result'} = { 'status' => 'failed', 'message' => $answer->{result} };
        }
        $c->forward('View::JSON');
 }