Explorar o código

feat(backendsrv): improves error response handling

datasourceRequests that could not reach the destination threw
invalid errors due to missing property. This fixes gives the user
a better error message.

closes #4428
bergquist %!s(int64=9) %!d(string=hai) anos
pai
achega
86a274a7ee
Modificáronse 1 ficheiros con 7 adicións e 0 borrados
  1. 7 0
      public/app/core/services/backend_srv.js

+ 7 - 0
public/app/core/services/backend_srv.js

@@ -105,6 +105,13 @@ function (angular, _, coreModule, config) {
           });
         }
 
+        //populate error obj on Internal Error
+        if (_.isString(err.data) && err.status === 500 && !err.data) {
+          err.data = {
+            error: err.statusText
+          };
+        }
+
         // for Prometheus
         if (!err.data.message && _.isString(err.data.error)) {
           err.data.message = err.data.error;