You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2018/11/26 18:44:45 UTC

[GitHub] graceguo-supercat closed pull request #6417: [bugfix] Display raw value in addition to ERROR

graceguo-supercat closed pull request #6417: [bugfix] Display raw value in addition to ERROR
URL: https://github.com/apache/incubator-superset/pull/6417
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/superset/assets/spec/javascripts/modules/utils_spec.jsx b/superset/assets/spec/javascripts/modules/utils_spec.jsx
index 0faaf31cb1..0970c8c7ae 100644
--- a/superset/assets/spec/javascripts/modules/utils_spec.jsx
+++ b/superset/assets/spec/javascripts/modules/utils_spec.jsx
@@ -29,7 +29,7 @@ describe('utils', () => {
       expect(d3format('.3s', 1234)).toBe('1.23k');
       expect(d3format('.3s', 1237)).toBe('1.24k');
       expect(d3format('', 1237)).toBe('1.24k');
-      expect(d3format('.2efd2.ef.2.e', 1237)).toBe('ERROR');
+      expect(d3format('.2efd2.ef.2.e', 1237)).toBe('1237 (Invalid format: .2efd2.ef.2.e)');
     });
   });
 
@@ -48,7 +48,7 @@ describe('utils', () => {
     });
     it('returns a working formatter', () => {
       expect(d3FormatPreset('smart_date')(0)).toBe('1970');
-      expect(d3FormatPreset('%%GIBBERISH')(0)).toBe('ERROR');
+      expect(d3FormatPreset('%%GIBBERISH')(0)).toBe('0 (Invalid format: %%GIBBERISH)');
     });
   });
 
diff --git a/superset/assets/src/modules/utils.js b/superset/assets/src/modules/utils.js
index 201d528dd4..a7f62327d7 100644
--- a/superset/assets/src/modules/utils.js
+++ b/superset/assets/src/modules/utils.js
@@ -6,7 +6,6 @@ import { timeFormat as d3TimeFormat } from 'd3-time-format';
 import { formatDate, UTC } from './dates';
 
 const siFormatter = d3Format('.3s');
-const ERROR_STRING = 'ERROR';
 
 export function defaultNumberFormatter(n) {
   let si = siFormatter(n);
@@ -28,7 +27,7 @@ export function d3FormatPreset(format) {
     } catch (e) {
       // eslint-disable-next-line no-console
       console.warn(e);
-      return () => ERROR_STRING;
+      return value => `${value} (Invalid format: ${format})`;
     }
   }
   return defaultNumberFormatter;
@@ -57,13 +56,13 @@ export function d3format(format, number) {
     } catch (e) {
       // eslint-disable-next-line no-console
       console.warn(e);
-      return ERROR_STRING;
+      return `${number} (Invalid format: ${format})`;
     }
   }
   try {
     return formatters[format](number);
   } catch (e) {
-    return ERROR_STRING;
+    return `${number} (Invalid format: ${format})`;
   }
 }
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org