LEVIATHAN vd52e79c4 · d52e79c486

Standard Library · ffi

class FfiException

The error raised by the foreign-function machinery.

since 0.1.0-alpha.1linuxwindowswasm

bases
RuntimeException

Overview

It is raised for a library or symbol that cannot be found, a library used after it was closed, exhausted callback slots, a null pointer given to view or toString, a call to a library that was not available when the program was built, and the stack and re-entry checks of foreign calls.

Examples

Catching the error

uses ffi;
use ffi;
use io::console;
try {
    throw ffi::FfiException("library 'plugin' was not available when this program was built");
} catch (RuntimeException e) {
    console.writeln("caught: " + e.message);
}
caught: library 'plugin' was not available when this program was built

Constructors

new

new(string msg)

Creates the error with a message.

Parameters

msg
The text describing what went wrong.

Examples

Making one

uses ffi;
use ffi;
use io::console;
ffi::FfiException e = ffi::FfiException("bad call");
console.writeln(e.message);
bad call