Skip to content

Commit

Permalink
Merge pull request #17 from stmcdonald-vt/transactionErrors
Browse files Browse the repository at this point in the history
errors seem to be formatted differently
  • Loading branch information
mappies authored Apr 12, 2024
2 parents 8be7b4d + c4eeaa1 commit 632a2fe
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nodenamo",
"version": "2.0.1",
"version": "2.0.2",
"description": "A powerful ORM for DynamoDb",
"main": "dist/index.js",
"typings": "dist/index",
Expand Down
49 changes: 27 additions & 22 deletions src/managers/dynamodbTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,36 +59,41 @@ export class DynamoDbTransaction
{
await transactionRequest;
}
catch(e)
catch(error)
{
try {
let error = JSON.parse(e.httpResponse.body.toString());

if(error.CancellationReasons)
{
let reasons = error.CancellationReasons;

for(let j = 0; j < reasons.length ; j++)
if (error.name === "TransactionCanceledException")
{
try {
if(error.CancellationReasons)
{
if(reasons[j].Code === 'None') continue;

let e = new Error(`${reasons[j].Code}: ${reasons[j].Message}: ${JSON.stringify(transactions[j])}`);

errors.push(e);
let reasons = error.CancellationReasons;

for(let j = 0; j < reasons.length ; j++)
{
if(reasons[j].Code === 'None') continue;

let e = new Error(`${reasons[j].Code}: ${reasons[j].Message}: ${JSON.stringify(transactions[j])}`);

errors.push(e);
}
}
}
else
else
{
errors.push(new Error(error.Message));
}

}
catch (err)
{
errors.push(new Error(error.message));
errors.push(err);
}

}
catch (err)
}
else
{
errors.push(err);
errors.push(error)
}

throw new AggregateError([e, ...errors]);
throw new AggregateError([error, ...errors]);
}
}
}
Expand Down

0 comments on commit 632a2fe

Please sign in to comment.