From 3672ba48a3d90640ab86cd58504629788ce2832b Mon Sep 17 00:00:00 2001 From: Daniel Harvey Date: Sun, 29 Mar 2020 14:27:27 +0800 Subject: [PATCH 1/3] Add UsageError example for `parseBlueprintOptions` [PR](https://github.com/balderdashy/sails/pull/6967) adds 'UsageError' handling for custom `parseBlueprintOptions()` errors. This is an example usage. --- reference/sails.config/sails.config.blueprints.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/reference/sails.config/sails.config.blueprints.md b/reference/sails.config/sails.config.blueprints.md index 111d0122b..cb1657637 100644 --- a/reference/sails.config/sails.config.blueprints.md +++ b/reference/sails.config/sails.config.blueprints.md @@ -46,6 +46,11 @@ parseBlueprintOptions: function(req) { if (queryOptions.criteria.limit > 100) { queryOptions.criteria.limit = 100; } + // NOTE: example, check about will prevent this error + if (queryOptions.criteria.limit > 100) { + let msg = 'Limit needs to be 100 or under'; + throw flaverr({ name: 'UsageError', code:'E_INVALID_LIMIT', details:msg }, new Error(msg)); + } } return queryOptions; From 8755fc26c69b9886786d9c5c1873a23084b8e082 Mon Sep 17 00:00:00 2001 From: Daniel Harvey Date: Sun, 29 Mar 2020 14:32:50 +0800 Subject: [PATCH 2/3] Correct typo --- reference/sails.config/sails.config.blueprints.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/sails.config/sails.config.blueprints.md b/reference/sails.config/sails.config.blueprints.md index cb1657637..951468e01 100644 --- a/reference/sails.config/sails.config.blueprints.md +++ b/reference/sails.config/sails.config.blueprints.md @@ -46,7 +46,7 @@ parseBlueprintOptions: function(req) { if (queryOptions.criteria.limit > 100) { queryOptions.criteria.limit = 100; } - // NOTE: example, check about will prevent this error + // NOTE: example, check above will prevent this error if (queryOptions.criteria.limit > 100) { let msg = 'Limit needs to be 100 or under'; throw flaverr({ name: 'UsageError', code:'E_INVALID_LIMIT', details:msg }, new Error(msg)); From c27c6075fefa27ef2a349d3b641000dde9b1830c Mon Sep 17 00:00:00 2001 From: Daniel Harvey Date: Sun, 29 Mar 2020 14:34:05 +0800 Subject: [PATCH 3/3] Clarified comment --- reference/sails.config/sails.config.blueprints.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/sails.config/sails.config.blueprints.md b/reference/sails.config/sails.config.blueprints.md index 951468e01..0d058d39b 100644 --- a/reference/sails.config/sails.config.blueprints.md +++ b/reference/sails.config/sails.config.blueprints.md @@ -46,7 +46,7 @@ parseBlueprintOptions: function(req) { if (queryOptions.criteria.limit > 100) { queryOptions.criteria.limit = 100; } - // NOTE: example, check above will prevent this error + // NOTE: example only, `if` check above will prevent this error code executing if (queryOptions.criteria.limit > 100) { let msg = 'Limit needs to be 100 or under'; throw flaverr({ name: 'UsageError', code:'E_INVALID_LIMIT', details:msg }, new Error(msg));