Skip to content

Commit

Permalink
Merge pull request #6116 from mzazrivec/correctly_catch_api_errors_wh…
Browse files Browse the repository at this point in the history
…en_creating_and_updating_ot

Correctly catch & handle API errors when creating orchestration template
  • Loading branch information
martinpovolny authored Sep 4, 2019
2 parents dcb5eb7 + bd3001d commit cf1aa2a
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ import MiqFormRenderer from '../../forms/data-driven-form';
import miqRedirectBack from '../../helpers/miq-redirect-back';
import orchestrationFormSchema from './orchestration-template-form.schema';

const submitNewTemplate = (values, message) => API.post('/api/orchestration_templates', values)
const submitNewTemplate = (values, message) => API.post('/api/orchestration_templates', values, {skipErrors: [400, 500]})
.then(() => miqRedirectBack(message, 'success', '/catalog/explorer'))
.catch(() => miqSparkleOff());
.catch((apiResult) => {
add_flash(apiResult.data.error.message, 'error');
miqSparkleOff()});

const updateTemplate = (values, message, otId) => API.patch(`/api/orchestration_templates/${otId}`, values)
const updateTemplate = (values, message, otId) => API.patch(`/api/orchestration_templates/${otId}`, values, {skipErrors: [400, 500]})
.then(() => miqRedirectBack(message, 'success', '/catalog/explorer'))
.catch(() => miqSparkleOff());
.catch((apiResult) => {
add_flash(apiResult.data.error.message, 'error');
miqSparkleOff()});

const copyTemplate = (values, message, otId) => API.post(`/api/orchestration_templates/${otId}`, {
action: 'copy',
Expand Down

0 comments on commit cf1aa2a

Please sign in to comment.