File tree Expand file tree Collapse file tree 3 files changed +32
-1
lines changed
plugins/vulnerable-chain-finder/src/main/java/eu/f4sten/vulchainfinder Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Original file line number Diff line number Diff line change 2424import eu .f4sten .infra .kafka .Message ;
2525import eu .f4sten .infra .kafka .MessageGenerator ;
2626import eu .f4sten .pomanalyzer .data .MavenId ;
27+ import eu .f4sten .vulchainfinder .exceptions .RestApiError ;
2728import eu .f4sten .vulchainfinder .utils .DatabaseUtils ;
2829import eu .f4sten .vulchainfinder .utils .ImpactPropagator ;
2930import eu .f4sten .vulchainfinder .utils .RestAPIDependencyResolver ;
@@ -151,6 +152,9 @@ public static MavenId extractMavenIdFrom(final Pom pom) {
151152 private void runOrPublishErr (final Runnable r ) {
152153 try {
153154 r .run ();
155+ } catch (RestApiError e ) {
156+ LOG .error ("Forced to stop the plug-in as the REST API is unavailable" , e );
157+ throw e ;
154158 } catch (Exception e ) {
155159 LOG .warn ("Execution failed for input: {}" , curId , e );
156160
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2022 Delft University of Technology
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+ package eu .f4sten .vulchainfinder .exceptions ;
18+
19+ /**
20+ * A custom exception for Rest API-related exception to stop the plug-in's container. This error is unrecoverable.
21+ */
22+ public class RestApiError extends Error {
23+ public RestApiError (String errorMsg , Throwable err ) {
24+ super (errorMsg , err );
25+ }
26+ }
Original file line number Diff line number Diff line change 11package eu .f4sten .vulchainfinder .utils ;
22
33import eu .f4sten .pomanalyzer .data .MavenId ;
4+ import eu .f4sten .vulchainfinder .exceptions .RestApiError ;
45import eu .fasten .core .data .metadatadb .codegen .tables .Dependencies ;
56import eu .fasten .core .data .metadatadb .codegen .tables .PackageVersions ;
67import java .io .IOException ;
@@ -83,7 +84,7 @@ public HttpResponse<String> sendOrThrow(final HttpRequest request) {
8384 exception = e ;
8485 }
8586 if (exception != null || response == null || isNotOK (response )) {
86- throw new RuntimeException ("Problem requesting Rest API." , exception );
87+ throw new RestApiError ("Problem requesting Rest API." , exception );
8788 }
8889
8990 return response ;
You can’t perform that action at this time.
0 commit comments