@defra/bng-errors-lib 0.78.0 → 0.79.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,15 @@
1
+ import { DuplicateApplicationReferenceError } from '../src/errors.js'
2
+
3
+ const applicationReference = 'mock application session ID'
4
+ const errorMessage = 'mock error message'
5
+
6
+ describe('Validation errors', () => {
7
+ it('should supplement a standard Error with an application session ID', async () => {
8
+ try {
9
+ throw new DuplicateApplicationReferenceError(applicationReference, errorMessage)
10
+ } catch (err) {
11
+ expect(err.applicationReference).toBe(applicationReference)
12
+ expect(err.message).toBe(errorMessage)
13
+ }
14
+ })
15
+ })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defra/bng-errors-lib",
3
- "version": "0.78.0",
3
+ "version": "0.79.0",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "description": "Custom errors for Biodiversity Net Gain",
@@ -15,5 +15,5 @@
15
15
  },
16
16
  "author": "Department for Environment, Food and Rural Affairs <https://www.gov.uk/government/organisations/department-for-environment-food-rural-affairs>",
17
17
  "license": "OGL-UK-3.0",
18
- "gitHead": "a39d32cf8be0ca535dec7997140e49cff27782d7"
18
+ "gitHead": "d0d8755f60f4dd4f8f60d79395858a01c8213907"
19
19
  }
@@ -0,0 +1,8 @@
1
+ // Adapted from https://medium.com/@xjamundx/custom-javascript-errors-in-es6-aa891b173f87
2
+ export default class DuplicateApplicationReferenceError extends Error {
3
+ constructor (applicationReference, ...args) {
4
+ super(...args)
5
+ this.applicationReference = applicationReference
6
+ Error.captureStackTrace(this, DuplicateApplicationReferenceError)
7
+ }
8
+ }
package/src/errors.js CHANGED
@@ -3,6 +3,7 @@ import ThreatScreeningError from './threat-screening-error.js'
3
3
  import UnknownApplicationSessionIdError from './unknown-application-session-id-error.js'
4
4
  import UploadTypeValidationError from './upload-type-validation-error.js'
5
5
  import ValidationError from './validation-error.js'
6
+ import DuplicateApplicationReferenceError from './duplicate-application-reference-error.js'
6
7
 
7
8
  const INVALID_COORDINATE_SYSTEM = 'INVALID-COORDINATE-SYSTEM'
8
9
  const INVALID_FEATURE_COUNT = 'INVALID-FEATURE-COUNT'
@@ -26,5 +27,6 @@ export {
26
27
  UnknownApplicationSessionIdError,
27
28
  UploadTypeValidationError,
28
29
  ValidationError,
30
+ DuplicateApplicationReferenceError,
29
31
  uploadGeospatialLandBoundaryErrorCodes
30
32
  }