Skip to content

Commit c705aa3

Browse files
committed
Improved error message
1 parent 2803807 commit c705aa3

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

src/main/java/org/utplsql/maven/plugin/UtPlsqlMojo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ private void setDbConfiguration() {
212212
}
213213
}
214214

215-
FileMapperOptions buildSourcesOptions() {
215+
FileMapperOptions buildSourcesOptions() throws MojoExecutionException {
216216
if (sources.isEmpty()) {
217217
File defaultSourceDirectory = new File(project.getBasedir(), Defaults.SOURCE_DIRECTORY);
218218
if (defaultSourceDirectory.exists()) {

src/main/java/org/utplsql/maven/plugin/io/SqlFileScanner.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.utplsql.maven.plugin.io;
22

33
import org.apache.maven.model.Resource;
4+
import org.apache.maven.plugin.MojoExecutionException;
45
import org.codehaus.plexus.util.DirectoryScanner;
56

67
import java.io.File;
@@ -27,7 +28,7 @@ public class SqlFileScanner {
2728
* @param defaultFilePattern the default file pattern
2829
* @return a list of the files found
2930
*/
30-
public List<String> findSqlScripts(File baseDir, List<Resource> resources, String defaultDirectory, String defaultFilePattern) {
31+
public List<String> findSqlScripts(File baseDir, List<Resource> resources, String defaultDirectory, String defaultFilePattern) throws MojoExecutionException {
3132
List<String> founds = new ArrayList<>();
3233

3334
for (Resource resource : resources) {
@@ -51,10 +52,10 @@ public List<String> findSqlScripts(File baseDir, List<Resource> resources, Strin
5152
return founds;
5253
}
5354

54-
private DirectoryScanner buildScanner(String baseDir, Resource resource) {
55+
private DirectoryScanner buildScanner(String baseDir, Resource resource) throws MojoExecutionException {
5556
File fileBaseDir = new File(baseDir, resource.getDirectory());
5657
if (!fileBaseDir.exists() || !fileBaseDir.isDirectory() || !fileBaseDir.canRead()) {
57-
throw new IllegalArgumentException(format("Invalid <directory> %s in resource. Check your pom.xml", resource.getDirectory()));
58+
throw new MojoExecutionException(format("Directory %s does not exist!", resource.getDirectory()));
5859
}
5960

6061
DirectoryScanner scanner = new DirectoryScanner();

src/test/java/org/utplsql/maven/plugin/MojoRuleTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public void invalidSourcesDirectory() throws Exception {
7878

7979
MojoExecutionException exception = assertThrows(MojoExecutionException.class, utplsqlMojo::execute);
8080

81-
assertEquals("Invalid <SOURCES> in your pom.xml", exception.getMessage());
81+
assertEquals("Directory foo does not exist!", exception.getMessage());
8282
}
8383

8484
/**
@@ -96,7 +96,7 @@ public void invalidTestsDirectory() throws Exception {
9696

9797
MojoExecutionException exception = assertThrows(MojoExecutionException.class, utplsqlMojo::execute);
9898

99-
assertEquals("Invalid <TESTS> in your pom.xml: Invalid <directory> bar in resource. Check your pom.xml", exception.getMessage());
99+
assertEquals("Directory bar does not exist!", exception.getMessage());
100100
}
101101

102102
/**

0 commit comments

Comments
 (0)