@defra-fish/dynamics-lib 1.77.0-rc.9 → 1.77.1
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-fish/dynamics-lib",
|
|
3
|
-
"version": "1.77.
|
|
3
|
+
"version": "1.77.1",
|
|
4
4
|
"description": "Framework to support integration with dynamics",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"simple-oauth2": "4.3.0",
|
|
44
44
|
"uuid": "8.3.2"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "3c12f0cae7daf9d931a85f1ab89e6ab7a218cb0a"
|
|
47
47
|
}
|
|
@@ -81,7 +81,10 @@ describe('entity manager', () => {
|
|
|
81
81
|
|
|
82
82
|
it('throws an error object on failure', async () => {
|
|
83
83
|
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(jest.fn())
|
|
84
|
-
|
|
84
|
+
const error = new Error('Test error')
|
|
85
|
+
const message = Symbol('We have a problem here')
|
|
86
|
+
error.error = { message }
|
|
87
|
+
MockDynamicsWebApi.__throwWithErrorsOnBatchExecute(error)
|
|
85
88
|
const newEntity = Object.assign(new TestEntity(), { strVal: 'test', intVal: 0 })
|
|
86
89
|
const existingEntity = TestEntity.fromResponse(
|
|
87
90
|
{
|
|
@@ -93,12 +96,13 @@ describe('entity manager', () => {
|
|
|
93
96
|
},
|
|
94
97
|
{}
|
|
95
98
|
)
|
|
96
|
-
await expect(persist([newEntity, existingEntity])).rejects.toThrow(
|
|
99
|
+
await expect(persist([newEntity, existingEntity])).rejects.toThrow(error)
|
|
97
100
|
// Expect the console error to contain details of the batch data (one create, one update plus the exception object)
|
|
98
101
|
expect(consoleErrorSpy).toHaveBeenCalledWith(
|
|
99
|
-
expect.stringMatching('Error persisting batch. Data: %j, Exception: %o'),
|
|
102
|
+
expect.stringMatching('Error persisting batch. Data: %j, Exception: %o, Message: %s'),
|
|
100
103
|
expect.arrayContaining([{ create: expect.any(Object) }, { update: expect.any(Object) }]),
|
|
101
|
-
|
|
104
|
+
error,
|
|
105
|
+
message
|
|
102
106
|
)
|
|
103
107
|
})
|
|
104
108
|
|
|
@@ -25,7 +25,7 @@ export async function persist (entities, createdBy) {
|
|
|
25
25
|
} catch (e) {
|
|
26
26
|
const error = e.length ? e[0] : e
|
|
27
27
|
const requestDetails = entities.map(entity => ({ [entity.isNew() ? 'create' : 'update']: entity.toPersistRequest() }))
|
|
28
|
-
console.error('Error persisting batch. Data: %j, Exception: %o', requestDetails, error)
|
|
28
|
+
console.error('Error persisting batch. Data: %j, Exception: %o, Message: %s', requestDetails, error, error?.error?.message)
|
|
29
29
|
throw error
|
|
30
30
|
}
|
|
31
31
|
}
|