diff options
author | Luke "Jared" Bennett <lbennett@gitlab.com> | 2017-05-16 16:39:13 +0000 |
---|---|---|
committer | Luke "Jared" Bennett <lbennett@gitlab.com> | 2017-05-16 16:39:13 +0000 |
commit | d4e150adc98cb59cf8595cd01b3e78ee22bc2b1f (patch) | |
tree | 1606a8b914395f0a12ee19c0f14d07c647ef28f9 | |
parent | 43befaf25f4f929d01a0af5ef3c2148002be7f4e (diff) | |
download | gitlab-ce-d4e150adc98cb59cf8595cd01b3e78ee22bc2b1f.tar.gz |
Update design_patterns.md to include maintainer decision on custom errors
-rw-r--r-- | doc/development/fe_guide/design_patterns.md | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/doc/development/fe_guide/design_patterns.md b/doc/development/fe_guide/design_patterns.md index e05887a19af..1555c2b1cc7 100644 --- a/doc/development/fe_guide/design_patterns.md +++ b/doc/development/fe_guide/design_patterns.md @@ -76,3 +76,43 @@ You can find an example of the above in this [class][container-class-example]; [container-class-example]: https://gitlab.com/gitlab-org/gitlab-ce/blob/master/app/assets/javascripts/mini_pipeline_graph_dropdown.js + +## Custom errors + +Custom/namespaced error are not accepted. You should just use a string. + +Example: + +### bad +```js +class NamespacedError extends Error { + ... custom Error logics ... +} + +const NamespacedObj = { + someMethod() { + throw NamespacedError; + } +}; + +try { + NamespacedObj.someMethod() +} catch (error) { + if (error instanceof NamespaceError) ... +} +``` + +### good +```js +const NamespacedObj = { + someMethod() { + throw 'some string'; + } +}; + +try { + NamespacedObj.someMethod() +} catch (error) { + if (error === 'some string') ... +} +```
\ No newline at end of file |