Function imageflow::imageflow_context_raise_error
[−]
[src]
#[no_mangle]pub unsafe extern fn imageflow_context_raise_error(context: *mut Context,
error_code: i32,
message: *const c_char,
filename: *const c_char,
line: i32,
function_name: *const c_char)
-> bool
Raises an error on the context.
Returns true on success, false if an error was already present.
Designed to be safe(ish) for use in out-of-memory scenarios; no additional allocations are made.
See imageflow_context_error_code for a list of error codes.
Expectations
- Strings
messageandfunction_name, andfilenameshould be null-terminated UTF-8 strings. - The lifetime of
messageis expected to exceed the duration of this function call. - The lifetime of
filenameandfunction_name(if provided), is expected to match or exceed the lifetime ofcontext. - You may provide a null value for
filenameorfunction_name, but for the love of puppies, don't provide a dangling or invalid pointer, that will segfault... a long time later.
Caveats
- You cannot raise a second error until the first has been cleared with
imageflow_context_clear_error. You'll be ignored, as will futureimageflow_add_to_callstackinvocations. - Behavior is undefined if
contextis a null or invalid ptr; segfault likely. - Behavior is undefined if
messageis an invalid ptr; immediate segfault likely. - If you provide an error code of zero (why?!), a different error code will be provided.