From 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Thu, 18 Feb 2021 10:34:06 +0000 Subject: Add latest changes from gitlab-org/gitlab@13-9-stable-ee --- app/assets/javascripts/snippets/utils/error.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 app/assets/javascripts/snippets/utils/error.js (limited to 'app/assets/javascripts/snippets/utils/error.js') diff --git a/app/assets/javascripts/snippets/utils/error.js b/app/assets/javascripts/snippets/utils/error.js new file mode 100644 index 00000000000..2d5c2a64038 --- /dev/null +++ b/app/assets/javascripts/snippets/utils/error.js @@ -0,0 +1,15 @@ +import { isString } from 'lodash'; +import { __ } from '~/locale'; + +export const UNEXPECTED_ERROR = __('Unexpected error'); + +export const getErrorMessage = (e) => { + if (!e) { + return UNEXPECTED_ERROR; + } + if (isString(e)) { + return e; + } + + return e.message || e.networkError || UNEXPECTED_ERROR; +}; -- cgit v1.2.1