Improve error message for mount point type mismatch.
RELNOTES: None.
@@ -305,15 +305,19 @@ final class LinuxSandboxedSpawnRunner extends AbstractSandboxSpawnRunner {
}
/**
- * This method does the following things: - If mount source does not exist on the host system,
- * throw an error message - If mount target exists, check whether the source and target are of the
- * same type - If mount target does not exist on the host system, throw an error message
+ * This method does the following things:
+ *
+ * <ul>
+ * <li>If mount source does not exist on the host system, throw an error message
+ * <li>If mount target exists, check whether the source and target are of the same type
+ * <li>If mount target does not exist on the host system, throw an error message
+ * </ul>
*
* @param bindMounts the bind mounts map with target as key and source as value
- * @throws UserExecException
+ * @throws UserExecException if any of the mount points are not valid
*/
private void validateBindMounts(SortedMap<Path, Path> bindMounts) throws UserExecException {
- for (SortedMap.Entry<Path, Path> bindMount : bindMounts.entrySet()) {
+ for (Map.Entry<Path, Path> bindMount : bindMounts.entrySet()) {
final Path source = bindMount.getValue();
final Path target = bindMount.getKey();
// Mount source should exist in the file system
@@ -334,8 +338,12 @@ final class LinuxSandboxedSpawnRunner extends AbstractSandboxSpawnRunner {
throw new UserExecException(
createFailureDetail(
String.format(
- "Mount target '%s' is not of the same type as mount source '%s'.",
- target, source),
+ "Mount target '%s' is a %s but mount source '%s' is a %s, they must be the"
+ + " same type.",
+ target,
+ (isTargetFile ? "file" : "directory"),
+ source,
+ (isSourceFile ? "file" : "directory")),
Code.MOUNT_SOURCE_TARGET_TYPE_MISMATCH));
}
} else {
