This is an automated email from the ASF dual-hosted git repository.

hugh pushed a commit to branch hugh/overwrite-generic-errors
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 89bf6274b35128d071cbe876c1ab3c5048ca392a
Author: hughhhh <[email protected]>
AuthorDate: Tue Apr 20 15:01:31 2021 -0700

    working overwrite with config
---
 superset-frontend/src/utils/textUtils.ts   | 2 +-
 superset-frontend/src/views/CRUD/utils.tsx | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/superset-frontend/src/utils/textUtils.ts 
b/superset-frontend/src/utils/textUtils.ts
index 9d8b7d9..585e346 100644
--- a/superset-frontend/src/utils/textUtils.ts
+++ b/superset-frontend/src/utils/textUtils.ts
@@ -15,6 +15,6 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import supersetText from '../../../superset_text';
+import supersetText from '../../../superset_text.yaml';
 
 export default supersetText || {};
diff --git a/superset-frontend/src/views/CRUD/utils.tsx 
b/superset-frontend/src/views/CRUD/utils.tsx
index 4096a96..7ab6e17 100644
--- a/superset-frontend/src/views/CRUD/utils.tsx
+++ b/superset-frontend/src/views/CRUD/utils.tsx
@@ -29,6 +29,7 @@ import rison from 'rison';
 import { getClientErrorObject } from 'src/utils/getClientErrorObject';
 import { FetchDataConfig } from 'src/components/ListView';
 import { Dashboard, Filters, SavedQueryObject } from './types';
+import SupersetText from 'src/utils/textUtils';
 
 const createFetchResourceMethod = (method: string) => (
   resource: string,
@@ -159,6 +160,11 @@ export function createErrorHandler(
 ) {
   return async (e: SupersetClientResponse | string) => {
     const parsedError = await getClientErrorObject(e);
+    // Taking the first error returned from the API
+    const errorType = parsedError?.errors?[0].error_type;
+    if(errorType in SupersetText.ERRORS) {
+      parsedError.message = SupersetText.ERRORS[errorType]
+    }
     logging.error(e);
     handleErrorFunc(parsedError.message || parsedError.error);
   };

Reply via email to