mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
fix error and error handling
This commit is contained in:
parent
e691db05b7
commit
de162647e5
@ -14,10 +14,10 @@ import { AbstractTransactionToDltRole } from './AbstractTransactionToDlt.role'
|
||||
export class TransactionLinkToDltRole extends AbstractTransactionToDltRole<TransactionLink> {
|
||||
async initWithLast(): Promise<this> {
|
||||
this.self = await this.createQueryForPendingItems(
|
||||
TransactionLink.createQueryBuilder().leftJoinAndSelect('transactionLink.user', 'user'),
|
||||
TransactionLink.createQueryBuilder().leftJoinAndSelect('TransactionLink.user', 'user'),
|
||||
'TransactionLink.id = dltTransaction.transactionLinkId',
|
||||
// eslint-disable-next-line camelcase
|
||||
{ TransactionLinkId_created_at: 'ASC', User_id: 'ASC' },
|
||||
{ TransactionLink_createdAt: 'ASC', User_id: 'ASC' },
|
||||
)
|
||||
return this
|
||||
}
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { EntityPropertyNotFoundError, QueryFailedError, TypeORMError } from '@dbTools/typeorm'
|
||||
import { Transaction } from '@entity/Transaction'
|
||||
import { TransactionLink } from '@entity/TransactionLink'
|
||||
import { User } from '@entity/User'
|
||||
@ -33,7 +34,6 @@ export async function transactionToDlt(dltConnector: DltConnectorClient): Promis
|
||||
})
|
||||
return results[0]
|
||||
}
|
||||
|
||||
while (true) {
|
||||
const pendingTransactionRole = await findNextPendingTransaction()
|
||||
const pendingTransaction = pendingTransactionRole.getEntity()
|
||||
@ -54,9 +54,6 @@ export async function transactionToDlt(dltConnector: DltConnectorClient): Promis
|
||||
error = 'skipped'
|
||||
}
|
||||
} catch (e) {
|
||||
if (e instanceof FetchError) {
|
||||
throw e
|
||||
}
|
||||
error = e instanceof Error ? e.message : String(e)
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
import { EntityPropertyNotFoundError } from '@dbTools/typeorm'
|
||||
import { TypeORMError } from '@dbTools/typeorm'
|
||||
// eslint-disable-next-line import/named, n/no-extraneous-import
|
||||
import { FetchError } from 'node-fetch'
|
||||
|
||||
@ -43,9 +43,6 @@ export async function sendTransactionsToDltConnector(): Promise<void> {
|
||||
1000,
|
||||
)
|
||||
} catch (e) {
|
||||
if (e instanceof EntityPropertyNotFoundError) {
|
||||
throw new LogError(e.message, e.stack)
|
||||
}
|
||||
// couldn't connect to dlt-connector? We wait
|
||||
if (e instanceof FetchError) {
|
||||
logger.error(`error connecting dlt-connector, wait 5 seconds before retry: ${String(e)}`)
|
||||
@ -54,7 +51,12 @@ export async function sendTransactionsToDltConnector(): Promise<void> {
|
||||
5000,
|
||||
)
|
||||
} else {
|
||||
logger.error(`Error while sending to DLT-connector or writing messageId`, e)
|
||||
if (e instanceof TypeORMError) {
|
||||
// seems to be a error in code, so let better stop here
|
||||
throw new LogError(e.message, e.stack)
|
||||
} else {
|
||||
logger.error(`Error while sending to DLT-connector or writing messageId`, e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user