Added error mapping for sleep timeout reached

This commit is contained in:
Inal Arsanukaev 2019-10-02 18:18:58 +03:00
parent cf9154435c
commit e31635300c
2 changed files with 4 additions and 5 deletions

View File

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.rbkmoney</groupId> <groupId>com.rbkmoney</groupId>
<artifactId>adapter-bank-payout-spring-boot-starter</artifactId> <artifactId>adapter-bank-payout-spring-boot-starter</artifactId>
<version>1.0.1</version> <version>1.0.2</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>Adapter-bank-payout-spring-boot-starter</name> <name>Adapter-bank-payout-spring-boot-starter</name>

View File

@ -4,7 +4,6 @@ import com.rbkmoney.adapter.bank.payout.spring.boot.starter.config.properties.Ti
import com.rbkmoney.adapter.bank.payout.spring.boot.starter.model.EntryStateModel; import com.rbkmoney.adapter.bank.payout.spring.boot.starter.model.EntryStateModel;
import com.rbkmoney.adapter.bank.payout.spring.boot.starter.model.ExitStateModel; import com.rbkmoney.adapter.bank.payout.spring.boot.starter.model.ExitStateModel;
import com.rbkmoney.damsel.base.Timer; import com.rbkmoney.damsel.base.Timer;
import com.rbkmoney.damsel.domain.Failure;
import com.rbkmoney.damsel.domain.TransactionInfo; import com.rbkmoney.damsel.domain.TransactionInfo;
import com.rbkmoney.damsel.withdrawals.provider_adapter.*; import com.rbkmoney.damsel.withdrawals.provider_adapter.*;
import com.rbkmoney.error.mapping.ErrorMapping; import com.rbkmoney.error.mapping.ErrorMapping;
@ -42,9 +41,9 @@ public class IntentServiceImpl implements IntentService {
throw new IllegalArgumentException("Need to specify 'maxTimePoolingMillis' before sleep"); throw new IllegalArgumentException("Need to specify 'maxTimePoolingMillis' before sleep");
} }
if (exitStateModel.getNextState().getMaxTimePoolingMillis() < Instant.now().toEpochMilli()) { if (exitStateModel.getNextState().getMaxTimePoolingMillis() < Instant.now().toEpochMilli()) {
final Failure failure = new Failure("Sleep timeout"); String code = "Sleep timeout";
failure.setReason("Max time pool limit reached"); String reason = "Max time pool limit reached";
return Intent.finish(new FinishIntent(FinishStatus.failure(failure))); return Intent.finish(new FinishIntent(FinishStatus.failure(errorMapping.mapFailure(code, reason))));
} }
int timerPollingDelay = OptionsExtractors.extractPollingDelay(exitStateModel.getEntryStateModel().getOptions(), timerProperties.getPollingDelay()); int timerPollingDelay = OptionsExtractors.extractPollingDelay(exitStateModel.getEntryStateModel().getOptions(), timerProperties.getPollingDelay());