Search in sources :

Example 1 with BadGlobException

use of com.google.devtools.build.lib.packages.Globber.BadGlobException in project bazel by bazelbuild.

the class PackageFactory method handleGlob.

/**
   * Adds a glob to the package, reporting any errors it finds.
   *
   * @param includes the list of includes which must be non-null
   * @param excludes the list of excludes which must be non-null
   * @param context the package context
   * @param ast the AST
   * @return the list of matches
   * @throws EvalException if globbing failed
   */
private static GlobList<String> handleGlob(List<String> includes, List<String> excludes, boolean excludeDirs, PackageContext context, FuncallExpression ast) throws EvalException, InterruptedException {
    try {
        Globber.Token globToken = context.globber.runAsync(includes, excludes, excludeDirs);
        List<String> matches = context.globber.fetch(globToken);
        return GlobList.captureResults(includes, excludes, matches);
    } catch (IOException expected) {
        context.eventHandler.handle(Event.error(ast.getLocation(), "error globbing [" + Joiner.on(", ").join(includes) + "]: " + expected.getMessage()));
        context.pkgBuilder.setContainsErrors();
        return GlobList.captureResults(includes, excludes, ImmutableList.<String>of());
    } catch (BadGlobException e) {
        throw new EvalException(ast.getLocation(), e.getMessage());
    }
}
Also used : BadGlobException(com.google.devtools.build.lib.packages.Globber.BadGlobException) IOException(java.io.IOException) EvalException(com.google.devtools.build.lib.syntax.EvalException)

Aggregations

BadGlobException (com.google.devtools.build.lib.packages.Globber.BadGlobException)1 EvalException (com.google.devtools.build.lib.syntax.EvalException)1 IOException (java.io.IOException)1