OSError
#struct OSErrorThe detail of an error.
| Name | Type | Description |
|---|---|---|
code | int = 0 | The error code; one of the constants above. |
message | str = "" | A short fixed English phrase such as mkdir failed; it does not carry the system's reason. |
operation | str = "" | The name of the function that failed. |
path | str = "" | The path that had the problem. |
system_code | int = 0 | The operating system's own error number when known; only os.process fills it in, everywhere else it is 0. |
import os.error
import fs
func main:
error.Clear()
println error.HasError()
fs.Delete("a file that does not exist.txt")
if error.HasError():
e := error.Last()
println e.code == error.FileNotFound, e.operation, e.message
println error.LastCode(), error.LastMessage()
end
error.Set(error.Timeout, "time ran out", "waiting", "", 0)
println error.LastCode() == error.Timeout, error.LastMessage()
println error.None,
error.PermissionDenied,
error.AlreadyExists,
error.InvalidPath,
error.NotSupported,
error.IOError,
error.ProcessFailed
endfalse true Delete delete failed 1 delete failed true time ran out 0 2 3 4 5 6 8