LEVIATHAN v962456e · 962456eee1

Standard Library

class FileException

The error thrown when a file operation fails.

since 0.1.0-alpha.1linuxwindowswasm

bases
Exception, IFileException

Overview

File throws it when a file cannot be opened (cannot open: <path>), when a file that is already open is opened again (already open: <path>), and when a file that is not open is closed (not open: <path>). The message holds that text with the path. A FileException is not a RuntimeException: catch FileException or IFileException to handle it.

Examples

try {
    File f = File("/no/such/file.txt", std::read);
    console.writeln("opened");
} catch (FileException e) {
    console.writeln("caught: ${e.message}");
}
caught: cannot open: /no/such/file.txt

Constructors

new

new(string msg)

Creates a file error with a message.

Parameters

msg
The text describing what went wrong.

Examples

try {
    throw FileException("disk full");
} catch (FileException e) {
    console.writeln(e.message);
}
disk full

See also

  • File — An open file.
  • IFileException — The interface of every error that comes from working with files.