]> source.dussan.org Git - sonarqube.git/commitdiff
fix promise rejection handler of condition creation
authorStas Vilchik <stas.vilchik@sonarsource.com>
Mon, 10 Dec 2018 10:45:22 +0000 (11:45 +0100)
committerSonarTech <sonartech@sonarsource.com>
Tue, 8 Jan 2019 19:21:05 +0000 (20:21 +0100)
server/sonar-web/src/main/js/api/quality-gates.ts
server/sonar-web/src/main/js/apps/quality-gates/components/ConditionModal.tsx

index c322b155fd1f067ff0b2ae37f51b6e6960ce9c82..7c1246f61743f6a2662a66bc30ee2c73165c7662 100644 (file)
@@ -79,13 +79,13 @@ export function createCondition(
     organization?: string;
   } & T.Omit<T.Condition, 'id'>
 ): Promise<T.Condition> {
-  return postJSON('/api/qualitygates/create_condition', data);
+  return postJSON('/api/qualitygates/create_condition', data).catch(throwGlobalError);
 }
 
 export function updateCondition(
   data: { organization?: string } & T.Condition
 ): Promise<T.Condition> {
-  return postJSON('/api/qualitygates/update_condition', data);
+  return postJSON('/api/qualitygates/update_condition', data).catch(throwGlobalError);
 }
 
 export function deleteCondition(data: { id: number; organization?: string }): Promise<void> {
index 1ee6de4631c00f60d3fab083ceadfd6be1cecedc..19a57ae35f026401dd5154494d2666d27e5729ab 100644 (file)
@@ -25,7 +25,6 @@ import Period from './Period';
 import { translate, getLocalizedMetricName } from '../../../helpers/l10n';
 import { createCondition, updateCondition } from '../../../api/quality-gates';
 import { isDiffMetric } from '../../../helpers/measures';
-import { parseError } from '../../../helpers/request';
 import ConfirmModal from '../../../components/controls/ConfirmModal';
 import { Alert } from '../../../components/ui/Alert';
 
@@ -100,16 +99,9 @@ export default class ConditionModal extends React.PureComponent<Props, State> {
       } else {
         submitPromise = createCondition({ gateId: qualityGate.id, organization, ...newCondition });
       }
-      return submitPromise.then(this.props.onAddCondition, (error: any) =>
-        parseError(error).then(message => {
-          if (this.mounted) {
-            this.setState({ errorMessage: message });
-          }
-          return Promise.reject(message);
-        })
-      );
+      return submitPromise.then(this.props.onAddCondition);
     }
-    return Promise.reject('No metric selected');
+    return Promise.reject();
   };
 
   handleChooseType = (metric: T.Metric) => {