pub fn get_tskit_error_message(code: i32) -> String
Expand description

Given a return value from low-level tskit function, obtain the corresponding error message.

tskit returns 0 when there’s no error:

let x = tskit::error::get_tskit_error_message(0);
assert_eq!(x, "Normal exit condition. This is not an error!");

Values > 0 are considered errors, but have no known type/cause. tskit never returns error codes > 0 and there should be no attempt to ever do so by client code.

let x = tskit::error::get_tskit_error_message(1);
assert_eq!(x, "Unknown error");

Values < 0 may have known causes:

let x = tskit::error::get_tskit_error_message(-207);
assert!(x.contains("Individual out of bounds"));

Panics

This function must allocate a C string, which may panic if the system runs out of memory.