1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from webkit-gir-files
// DO NOT EDIT
use crate::{ffi, Context};
use glib::translate::*;
glib::wrapper! {
/// JSCException represents a JavaScript exception.
#[doc(alias = "JSCException")]
pub struct Exception(Object<ffi::JSCException, ffi::JSCExceptionClass>);
match fn {
type_ => || ffi::jsc_exception_get_type(),
}
}
impl Exception {
/// Create a new #JSCException in @context with @message.
/// ## `context`
/// a #JSCContext
/// ## `message`
/// the error message
///
/// # Returns
///
/// a new #JSCException.
#[doc(alias = "jsc_exception_new")]
pub fn new(context: &Context, message: &str) -> Exception {
skip_assert_initialized!();
unsafe {
from_glib_full(ffi::jsc_exception_new(
context.to_glib_none().0,
message.to_glib_none().0,
))
}
}
//#[doc(alias = "jsc_exception_new_printf")]
//pub fn new_printf(context: &Context, format: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> Exception {
// unsafe { TODO: call ffi:jsc_exception_new_printf() }
//}
//#[doc(alias = "jsc_exception_new_vprintf")]
//pub fn new_vprintf(context: &Context, format: &str, args: /*Unknown conversion*//*Unimplemented*/Unsupported) -> Exception {
// unsafe { TODO: call ffi:jsc_exception_new_vprintf() }
//}
/// Create a new #JSCException in @context with @name and @message.
/// ## `context`
/// a #JSCContext
/// ## `name`
/// the error name
/// ## `message`
/// the error message
///
/// # Returns
///
/// a new #JSCException.
#[doc(alias = "jsc_exception_new_with_name")]
#[doc(alias = "new_with_name")]
pub fn with_name(context: &Context, name: &str, message: &str) -> Exception {
skip_assert_initialized!();
unsafe {
from_glib_full(ffi::jsc_exception_new_with_name(
context.to_glib_none().0,
name.to_glib_none().0,
message.to_glib_none().0,
))
}
}
//#[doc(alias = "jsc_exception_new_with_name_printf")]
//#[doc(alias = "new_with_name_printf")]
//pub fn with_name_printf(context: &Context, name: &str, format: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> Exception {
// unsafe { TODO: call ffi:jsc_exception_new_with_name_printf() }
//}
//#[doc(alias = "jsc_exception_new_with_name_vprintf")]
//#[doc(alias = "new_with_name_vprintf")]
//pub fn with_name_vprintf(context: &Context, name: &str, format: &str, args: /*Unknown conversion*//*Unimplemented*/Unsupported) -> Exception {
// unsafe { TODO: call ffi:jsc_exception_new_with_name_vprintf() }
//}
/// Get a string with the exception backtrace.
///
/// # Returns
///
/// the exception backtrace string or [`None`].
#[doc(alias = "jsc_exception_get_backtrace_string")]
#[doc(alias = "get_backtrace_string")]
pub fn backtrace_string(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::jsc_exception_get_backtrace_string(
self.to_glib_none().0,
))
}
}
/// Get the column number at which @self happened.
///
/// # Returns
///
/// the column number of @self.
#[doc(alias = "jsc_exception_get_column_number")]
#[doc(alias = "get_column_number")]
pub fn column_number(&self) -> u32 {
unsafe { ffi::jsc_exception_get_column_number(self.to_glib_none().0) }
}
/// Get the line number at which @self happened.
///
/// # Returns
///
/// the line number of @self.
#[doc(alias = "jsc_exception_get_line_number")]
#[doc(alias = "get_line_number")]
pub fn line_number(&self) -> u32 {
unsafe { ffi::jsc_exception_get_line_number(self.to_glib_none().0) }
}
/// Get the error message of @self.
///
/// # Returns
///
/// the @self error message.
#[doc(alias = "jsc_exception_get_message")]
#[doc(alias = "get_message")]
pub fn message(&self) -> Option<glib::GString> {
unsafe { from_glib_none(ffi::jsc_exception_get_message(self.to_glib_none().0)) }
}
/// Get the error name of @self
///
/// # Returns
///
/// the @self error name.
#[doc(alias = "jsc_exception_get_name")]
#[doc(alias = "get_name")]
pub fn name(&self) -> Option<glib::GString> {
unsafe { from_glib_none(ffi::jsc_exception_get_name(self.to_glib_none().0)) }
}
/// Get the source URI of @self.
///
/// # Returns
///
/// the the source URI of @self, or [`None`].
#[doc(alias = "jsc_exception_get_source_uri")]
#[doc(alias = "get_source_uri")]
pub fn source_uri(&self) -> Option<glib::GString> {
unsafe { from_glib_none(ffi::jsc_exception_get_source_uri(self.to_glib_none().0)) }
}
/// Return a report message of @self, containing all the possible details such us
/// source URI, line, column and backtrace, and formatted to be printed.
///
/// # Returns
///
/// a new string with the exception report
#[doc(alias = "jsc_exception_report")]
pub fn report(&self) -> Option<glib::GString> {
unsafe { from_glib_full(ffi::jsc_exception_report(self.to_glib_none().0)) }
}
/// Get the string representation of @self error.
///
/// # Returns
///
/// the string representation of @self.
#[doc(alias = "jsc_exception_to_string")]
#[doc(alias = "to_string")]
pub fn to_str(&self) -> glib::GString {
unsafe { from_glib_full(ffi::jsc_exception_to_string(self.to_glib_none().0)) }
}
}
impl std::fmt::Display for Exception {
#[inline]
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.write_str(&self.to_str())
}
}