Navigation
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.
Remedies:
  • 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.
Examples
rascal>import IO;
ok
Reading a non-existing URI gives an error:
rascal>readFile(|http://www.cwi.nl/does_not_exist|);
|stdin:///|(9,34,<1,9>,<1,43>): PathNotFound(|http://www.cwi.nl/does_not_exist|)
	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 ask.rascal-mpl.org.