Synopsis A requested path name cannot be found.
Function data RunTimeException = PathNotFound(loc location);
Usage import Exception;
Description The PathNotFound error is generated in all cases where access to the requested location is impossible. This includes:
  • A non-existing path.
  • A non-existing file.
  • Insufficient rights to read/write the file.
  • Check that the path is correct.
  • Check that the resource exists.
  • When using the file scheme:
    • Check that you have read/write access to the file.
    • When you use an absolute path name, your location should always start with 3 slash (/) characters:
      • |file:///users/paulklint/file.txt| is correct.
      • |file://users/paulklint/file.txt| gives a PathNotFound error.
    • When you use a relative path name, make sure that it is relative to the directory from which Rascal was started.
  • Catch the PathNotFound yourself, see Rascal:TryCatch.
rascal>import IO;
Reading a non-existing URI gives an error:
|stdin:///|(9,34,<1,9>,<1,43>): PathNotFound(||)
	at *** somewhere ***(|stdin:///|(9,34,<1,9>,<1,43>))
	at readFile(|stdin:///|(9,34,<1,9>,<1,43>))

Trying to write to a file for which we do not have write access (don't run this as superuser!) als gives an error:
rascal>writeFile(|file:///etc/passwd|, "A BAD idea!");
|stdin:///|(32,13,<1,32>,<1,45>): PathNotFound(|file:///etc/passwd|)
	at *** somewhere ***(|stdin:///|(32,13,<1,32>,<1,45>))
	at writeFile(|stdin:///|(32,13,<1,32>,<1,45>))

Is this page unclear, or have you spotted an error? Please add a comment below and help us to improve it. For all other questions and remarks, visit