Commit 52f5de3b authored by Jose Vargas's avatar Jose Vargas

Add sentry error handling to the job actions component

parent 1ded4b19
...@@ -18,6 +18,7 @@ import cancelJobMutation from '../graphql/mutations/job_cancel.mutation.graphql' ...@@ -18,6 +18,7 @@ import cancelJobMutation from '../graphql/mutations/job_cancel.mutation.graphql'
import playJobMutation from '../graphql/mutations/job_play.mutation.graphql'; import playJobMutation from '../graphql/mutations/job_play.mutation.graphql';
import retryJobMutation from '../graphql/mutations/job_retry.mutation.graphql'; import retryJobMutation from '../graphql/mutations/job_retry.mutation.graphql';
import unscheduleJobMutation from '../graphql/mutations/job_unschedule.mutation.graphql'; import unscheduleJobMutation from '../graphql/mutations/job_unschedule.mutation.graphql';
import { reportMessageToSentry } from '../../../utils';
export default { export default {
ACTIONS_DOWNLOAD_ARTIFACTS, ACTIONS_DOWNLOAD_ARTIFACTS,
...@@ -34,6 +35,7 @@ export default { ...@@ -34,6 +35,7 @@ export default {
jobPlay: 'jobPlay', jobPlay: 'jobPlay',
jobUnschedule: 'jobUnschedule', jobUnschedule: 'jobUnschedule',
playJobModalId: 'play-job-modal', playJobModalId: 'play-job-modal',
name: 'JobActionsCell',
components: { components: {
GlButton, GlButton,
GlButtonGroup, GlButtonGroup,
...@@ -99,15 +101,17 @@ export default { ...@@ -99,15 +101,17 @@ export default {
variables: { id: this.job.id }, variables: { id: this.job.id },
}); });
if (errors.length > 0) { if (errors.length > 0) {
this.reportFailure(); reportMessageToSentry(this.$options.name, errors.join(', '), {});
this.showToastMessage();
} else { } else {
eventHub.$emit('jobActionPerformed'); eventHub.$emit('jobActionPerformed');
} }
} catch { } catch (failure) {
this.reportFailure(); reportMessageToSentry(this.$options.name, failure, {});
this.showToastMessage();
} }
}, },
reportFailure() { showToastMessage() {
const toastProps = { const toastProps = {
text: this.$options.GENERIC_ERROR, text: this.$options.GENERIC_ERROR,
variant: 'danger', variant: 'danger',
......
...@@ -19,3 +19,12 @@ export const reportToSentry = (component, failureType) => { ...@@ -19,3 +19,12 @@ export const reportToSentry = (component, failureType) => {
Sentry.captureException(failureType); Sentry.captureException(failureType);
}); });
}; };
export const reportMessageToSentry = (component, message, context) => {
Sentry.withScope((scope) => {
// eslint-disable-next-line @gitlab/require-i18n-strings
scope.setContext('Vue data', context);
scope.setTag('component', component);
Sentry.captureMessage(message);
});
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment