superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grace...@apache.org
Subject [incubator-superset] branch master updated: [bugfix] Display raw value in addition to ERROR (#6417)
Date Mon, 26 Nov 2018 18:44:48 GMT
This is an automated email from the ASF dual-hosted git repository.

graceguo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 3c6e882  [bugfix] Display raw value in addition to ERROR (#6417)
3c6e882 is described below

commit 3c6e882d282515315a8bc9bb0346ac3d21ff61a7
Author: Krist Wongsuphasawat <krist.wongz@gmail.com>
AuthorDate: Mon Nov 26 10:44:42 2018 -0800

    [bugfix] Display raw value in addition to ERROR (#6417)
    
    * Display raw value in addition to ERROR
    
    * update unit test
---
 superset/assets/spec/javascripts/modules/utils_spec.jsx | 4 ++--
 superset/assets/src/modules/utils.js                    | 7 +++----
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/superset/assets/spec/javascripts/modules/utils_spec.jsx b/superset/assets/spec/javascripts/modules/utils_spec.jsx
index 0faaf31..0970c8c 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 201d528..a7f6232 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})`;
   }
 }
 


Mime
View raw message