Skip to content

openUrl ​

openUrl opens url with the platform's default handler (browser, mail client, etc.), the same effect as double-clicking a link.

SignatureopenUrl(url: string): Result<void, OsError>
tyrus
import { OsError, openUrl } from "tyrus:os";

match (openUrl("https://example.com")) {
    Ok() => print("URL opened"); // URL opened
    Err(error) => printError(`${error.code}: ${error.message}`); // ERR_OS_NO_HANDLER: no application is registered to open this URL
}

Returns Err(OsError) (code: "ERR_OS_NO_HANDLER") if no application is registered to open url.

OsError Fields ​

FieldTypeMeaning
codestringA stable, machine-readable identifier (e.g. "ERR_OS_NO_HANDLER").
messagestringA human-readable description of what went wrong.