summaryrefslogtreecommitdiff
path: root/doc/development/fe_guide
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-03-21 12:08:46 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-03-21 12:08:46 +0000
commit7f521d27811b472c43203ed3d1bde4460a617f89 (patch)
tree47f1a10b776991e86c6db002bc6e03e83acc356a /doc/development/fe_guide
parent83e3316a189d3b709b23af30647b5f9ea5377bac (diff)
downloadgitlab-ce-7f521d27811b472c43203ed3d1bde4460a617f89.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'doc/development/fe_guide')
-rw-r--r--doc/development/fe_guide/content_editor.md4
-rw-r--r--doc/development/fe_guide/style/javascript.md20
2 files changed, 14 insertions, 10 deletions
diff --git a/doc/development/fe_guide/content_editor.md b/doc/development/fe_guide/content_editor.md
index 5c7fe68fec5..25140a067ca 100644
--- a/doc/development/fe_guide/content_editor.md
+++ b/doc/development/fe_guide/content_editor.md
@@ -1,6 +1,6 @@
---
-stage: Create
-group: Editor
+stage: Plan
+group: Knowledge
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/product/ux/technical-writing/#assignments
---
diff --git a/doc/development/fe_guide/style/javascript.md b/doc/development/fe_guide/style/javascript.md
index b35ffdd8669..be5208e9b55 100644
--- a/doc/development/fe_guide/style/javascript.md
+++ b/doc/development/fe_guide/style/javascript.md
@@ -332,19 +332,23 @@ Only export the constants as a collection (array, or object) when there is a nee
## Error handling
-When catching a server-side error you should use the error message
+When catching a server-side error, you should use the error message
utility function contained in `app/assets/javascripts/lib/utils/error_message.js`.
-This utility parses the received error message and checks for a prefix that indicates
-whether the message is meant to be user-facing or not. The utility returns
-an object with the message, and a boolean indicating whether the message is meant to be user-facing or not. Please make sure that the Backend is aware of the utils usage and is adding the prefix
-to the error message accordingly.
+This utility accepts two parameters: the error object received from the server response and a
+default error message. The utility examines the message in the error object for a prefix that
+indicates whether the message is meant to be user-facing or not. If the message is intended
+to be user-facing, the utility returns it as is. Otherwise, it returns the default error
+message passed as a parameter.
```javascript
import { parseErrorMessage } from '~/lib/utils/error_message';
onError(error) {
- const { message, userFacing } = parseErrorMessage(error);
-
- const errorMessage = userFacing ? message : genericErrorText;
+ const errorMessage = parseErrorMessage(error, genericErrorText);
}
```
+
+To benefit from this parsing mechanism, the utility user should ensure that the server-side
+code is aware of this utility's usage and prefixes the error messages where appropriate
+before sending them back to the user. See
+[Error handling for API](../../api_styleguide.md#error-handling) for more information.