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

(cherry picked from commit cf1aa2a)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1767648
  • Loading branch information
martinpovolny authored and simaishi committed Oct 31, 2019
1 parent 8be4148 commit c0690a6
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 c0690a6

Please sign in to comment.