@defra/bng-errors-lib 1.172.0 → 1.174.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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defra/bng-errors-lib",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.174.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": "
|
|
18
|
+
"gitHead": "b7bfe277bdca6825f92c900e543fe40b38445858"
|
|
19
19
|
}
|
package/src/errors.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import CoordinateSystemValidationError from './coordinate-system-validation-error.js'
|
|
2
1
|
import ThreatScreeningError from './threat-screening-error.js'
|
|
3
2
|
import MalwareDetectedError from './malware-detected-error.js'
|
|
4
3
|
import UnknownApplicationSessionIdError from './unknown-application-session-id-error.js'
|
|
@@ -6,36 +5,20 @@ import UploadTypeValidationError from './upload-type-validation-error.js'
|
|
|
6
5
|
import ValidationError from './validation-error.js'
|
|
7
6
|
import DuplicateApplicationReferenceError from './duplicate-application-reference-error.js'
|
|
8
7
|
|
|
9
|
-
const INVALID_COORDINATE_SYSTEM = 'INVALID-COORDINATE-SYSTEM'
|
|
10
|
-
const INVALID_FEATURE_COUNT = 'INVALID-FEATURE-COUNT'
|
|
11
|
-
const INVALID_LAYER_COUNT = 'INVALID-LAYER-COUNT'
|
|
12
8
|
const INVALID_UPLOAD = 'INVALID-UPLOAD'
|
|
13
|
-
const MISSING_COORDINATE_SYSTEM = 'MISSING-COORDINATE-SYSTEM'
|
|
14
|
-
const OUTSIDE_ENGLAND = 'OUTSIDE_ENGLAND'
|
|
15
9
|
const EMPTY_FILE_UPLOAD = 'EMPTY_FILE_UPLOAD'
|
|
16
10
|
|
|
17
|
-
const uploadGeospatialLandBoundaryErrorCodes = Object.freeze({
|
|
18
|
-
INVALID_COORDINATE_SYSTEM,
|
|
19
|
-
INVALID_FEATURE_COUNT,
|
|
20
|
-
INVALID_LAYER_COUNT,
|
|
21
|
-
INVALID_UPLOAD,
|
|
22
|
-
MISSING_COORDINATE_SYSTEM,
|
|
23
|
-
OUTSIDE_ENGLAND
|
|
24
|
-
})
|
|
25
|
-
|
|
26
11
|
const uploadWrittenConsentErrorCodes = Object.freeze({
|
|
27
12
|
INVALID_UPLOAD,
|
|
28
13
|
EMPTY_FILE_UPLOAD
|
|
29
14
|
})
|
|
30
15
|
|
|
31
16
|
export {
|
|
32
|
-
CoordinateSystemValidationError,
|
|
33
17
|
ThreatScreeningError,
|
|
34
18
|
MalwareDetectedError,
|
|
35
19
|
UnknownApplicationSessionIdError,
|
|
36
20
|
UploadTypeValidationError,
|
|
37
21
|
ValidationError,
|
|
38
22
|
DuplicateApplicationReferenceError,
|
|
39
|
-
uploadGeospatialLandBoundaryErrorCodes,
|
|
40
23
|
uploadWrittenConsentErrorCodes
|
|
41
24
|
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { CoordinateSystemValidationError } from '../src/errors.js'
|
|
2
|
-
|
|
3
|
-
const authorityKey = 'mock authority key'
|
|
4
|
-
const errorCode = 'mock error code'
|
|
5
|
-
const errorMessage = 'mock error message'
|
|
6
|
-
|
|
7
|
-
describe('Coordinate system validation errors', () => {
|
|
8
|
-
it('should supplement a standard Error with an authority key and error code', async () => {
|
|
9
|
-
try {
|
|
10
|
-
throw new CoordinateSystemValidationError(authorityKey, errorCode, errorMessage)
|
|
11
|
-
} catch (err) {
|
|
12
|
-
expect(err.authorityKey).toBe(authorityKey)
|
|
13
|
-
expect(err.code).toBe(errorCode)
|
|
14
|
-
expect(err.message).toBe(errorMessage)
|
|
15
|
-
}
|
|
16
|
-
})
|
|
17
|
-
})
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import ValidationError from './validation-error.js'
|
|
2
|
-
|
|
3
|
-
// Adapted from https://medium.com/@xjamundx/custom-javascript-errors-in-es6-aa891b173f87
|
|
4
|
-
export default class CoordinateSystemValidationError extends ValidationError {
|
|
5
|
-
constructor (authorityKey, code, ...args) {
|
|
6
|
-
super(code, ...args)
|
|
7
|
-
this.authorityKey = authorityKey
|
|
8
|
-
Error.captureStackTrace(this, CoordinateSystemValidationError)
|
|
9
|
-
}
|
|
10
|
-
}
|