Skip to content

Commit

Permalink
Properly handle case when quarkus-extension.yaml doesn't exist
Browse files Browse the repository at this point in the history
We need to catch the NoSuchFileException and ignore it.

Per gripe from Marco Bungart in the Quarkus Artemis project.
  • Loading branch information
gsmet committed Aug 14, 2024
1 parent 1466fcc commit 2c87bb5
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.io.UncheckedIOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Map;
Expand Down Expand Up @@ -158,9 +159,14 @@ public Optional<Map<String, Object>> getExtensionMetadata() {

return Optional.of(extensionMetadata);
}
} catch (NoSuchFileException e) {
// ignore
// we could get the URI, create a Path and check that the path exists but it seems a bit overkill
return Optional.empty();
} catch (IOException e) {
processingEnv.getMessager().printMessage(Kind.WARNING,
"Unable to read extension metadata file: " + extensionMetadataDescriptor + " because of " + e.getMessage());
"Unable to read extension metadata file: " + extensionMetadataDescriptor + " because of "
+ e.getClass().getName() + ": " + e.getMessage());
return Optional.empty();
}
}
Expand Down

0 comments on commit 2c87bb5

Please sign in to comment.