Skip to content

Commit b0e14d0

Browse files
fix: Handle org.apache.cxf.transport.http.HTTPException (#121)
1 parent c686e9f commit b0e14d0

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

core/src/main/java/io/github/project/openubl/xsender/camel/routes/SunatRouteBuilder.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
package io.github.project.openubl.xsender.camel.routes;
1818

1919
import io.github.project.openubl.xsender.Constants;
20+
import io.github.project.openubl.xsender.models.Metadata;
21+
import io.github.project.openubl.xsender.models.Status;
22+
import io.github.project.openubl.xsender.models.SunatResponse;
2023
import io.github.project.openubl.xsender.models.rest.ResponseAccessTokenSuccessDto;
2124
import io.github.project.openubl.xsender.models.rest.ResponseDocumentErrorDto;
2225
import io.github.project.openubl.xsender.models.rest.ResponseDocumentSuccessDto;
@@ -31,9 +34,11 @@
3134
import org.apache.camel.model.dataformat.JsonLibrary;
3235
import org.apache.camel.util.URISupport;
3336
import org.apache.cxf.binding.soap.SoapFault;
37+
import org.apache.cxf.transport.http.HTTPException;
3438

3539
import java.net.URISyntaxException;
3640
import java.time.ZonedDateTime;
41+
import java.util.Collections;
3742
import java.util.List;
3843
import java.util.Map;
3944
import java.util.Objects;
@@ -68,6 +73,25 @@ public void configure() {
6873
.continued(true)
6974
.process(new SoapSunatErrorResponseProcessor())
7075
.end()
76+
.onException(HTTPException.class)
77+
.continued(true)
78+
.maximumRedeliveries(1)
79+
.useOriginalMessage()
80+
.process(exchange -> {
81+
Throwable throwable = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Throwable.class);
82+
83+
SunatResponse sunatResponse = SunatResponse.builder()
84+
.status(Status.UNKNOWN)
85+
.metadata(Metadata.builder()
86+
.notes(Collections.emptyList())
87+
.description(throwable.getMessage())
88+
.build())
89+
.build();
90+
91+
exchange.getIn().setBody(sunatResponse);
92+
})
93+
.end()
94+
7195
// REST exception
7296
.onException(HttpOperationFailedException.class)
7397
.continued(exchange -> {

quarkus-extension/deployment/src/main/java/io/github/project/openubl/quarkus/xsender/deployment/QuarkusXsenderProcessor.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@
1717
package io.github.project.openubl.quarkus.xsender.deployment;
1818

1919
import io.github.project.openubl.quarkus.xsender.XSender;
20-
import io.github.project.openubl.xsender.camel.routes.SoapSunatErrorResponseProcessor;
21-
import io.github.project.openubl.xsender.camel.routes.SoapSunatResponseProcessor;
2220
import io.github.project.openubl.xsender.camel.routes.SunatRouteBuilder;
23-
import io.github.project.openubl.xsender.sunat.BillServiceDestination;
2421
import io.quarkus.arc.deployment.AdditionalBeanBuildItem;
2522
import io.quarkus.arc.processor.DotNames;
2623
import io.quarkus.deployment.annotations.BuildProducer;
@@ -134,7 +131,8 @@ ReflectiveClassBuildItem soapReflection() {
134131
return new ReflectiveClassBuildItem(
135132
true,
136133
false,
137-
org.apache.cxf.binding.soap.SoapFault.class
134+
org.apache.cxf.binding.soap.SoapFault.class,
135+
org.apache.cxf.transport.http.HTTPException.class
138136
);
139137
}
140138

0 commit comments

Comments
 (0)