Fix error reporting of non-json error responses

Change-Id: I19f67e92b09a41db09509b3b07e04ef2f8a7d2a2
diff --git a/lib/Kalamar/API.pm b/lib/Kalamar/API.pm
index d48a660..c58b2c7 100644
--- a/lib/Kalamar/API.pm
+++ b/lib/Kalamar/API.pm
@@ -111,7 +111,6 @@
     $c->user->auth_request(
       get => $url => sub {
         my $tx = pop;
-
         $self->_process_response('matches', $index, $tx);
         weaken $index;
         return $cb->($index);
@@ -351,7 +350,7 @@
   if (my $e = $tx->error) {
 
     # Send error
-    $self->_notify_on_error($c, 0, $tx->res->json);
+    $self->_notify_on_error($c, 1, $tx->res);
 
     # $c->notify(
     # error =>
diff --git a/lib/Kalamar/Apps/test_backend.pl b/lib/Kalamar/Apps/test_backend.pl
index 9d851f1..c00ab6b 100644
--- a/lib/Kalamar/Apps/test_backend.pl
+++ b/lib/Kalamar/Apps/test_backend.pl
@@ -128,6 +128,14 @@
     });
   };
 
+  if ($v->param('q') && $v->param('q') eq 'server_fail') {
+    return $c->render(
+      status => 500,
+      inline => 'Oooops'
+    );
+
+  };
+
   if (my $auth = $c->req->headers->header('Authorization')) {
     if (my $jwt = $c->jwt_decode($auth)) {
       $response->{meta}->{authorized} = $jwt->{username} if $jwt->{username};
diff --git a/t/remote.t b/t/remote.t
index ccb4f67..4828b85 100644
--- a/t/remote.t
+++ b/t/remote.t
@@ -48,7 +48,11 @@
   ;
 
 
-
+# Check for server error
+$t->get_ok('/?q=server_fail&ql=poliqarp')
+  ->element_exists('.notify-error')
+  ->text_is('.notify-error', '500: Internal Server Error (remote)')
+  ;
 
 done_testing;
 __END__