File tree Expand file tree Collapse file tree 3 files changed +8
-5
lines changed
test/unit/specs/transactions Expand file tree Collapse file tree 3 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -7,9 +7,10 @@ import { OpResult } from './op-result'
77import { OpResultValueReference } from './op-result-value-reference'
88
99class TransactionOperationError extends Error {
10- constructor ( message , operation ) {
11- super ( message )
10+ constructor ( error , operation ) {
11+ super ( error . message )
1212
13+ this . code = error . code
1314 this . operation = operation
1415 }
1516
@@ -143,7 +144,7 @@ class UnitOfWork {
143144 return result . error . operation . opResultId === op . meta . opResult . getOpResultId ( )
144145 } )
145146
146- result . error = new TransactionOperationError ( result . error . message , operation . meta . opResult )
147+ result . error = new TransactionOperationError ( result . error , operation . meta . opResult )
147148
148149 operation . meta . opResult . setError ( result . error )
149150 }
Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ describe('<Transactions> Basic', function() {
6363 opResultId : 'createPerson1' ,
6464 operationType : 'CREATE' ,
6565 payload : obj ,
66- } )
66+ } , 1234 )
6767
6868 const createOpResult = uow . create ( PERSONS_TABLE_NAME , obj )
6969
@@ -78,6 +78,7 @@ describe('<Transactions> Basic', function() {
7878 expect ( createOpResult . error ) . to . equal ( createOpResult . getError ( ) )
7979
8080 expect ( uowResult . error . operation ) . to . equal ( createOpResult )
81+ expect ( uowResult . error . code ) . to . equal ( 1234 )
8182 } )
8283
8384 it ( 'converts a TransactionOperationError to JSON' , async ( ) => {
Original file line number Diff line number Diff line change @@ -10,13 +10,14 @@ export function prepareSuccessResponse(results) {
1010 } ) )
1111}
1212
13- export function prepareErrorResponse ( message , operation ) {
13+ export function prepareErrorResponse ( message , operation , code ) {
1414 return prepareMockRequest ( ( ) => ( {
1515 body : {
1616 success : false ,
1717 results : null ,
1818 error : {
1919 message,
20+ code,
2021 operation
2122 } ,
2223 }
You can’t perform that action at this time.
0 commit comments