wp_lib_error_codes - roberts-sandbox/create-repo GitHub Wiki
###Description
This filter is applied to WP-Librarian's list of error codes, allowing you to add your own error codes or modify existing errors and their descriptions.
When adding entries to the array use strings rather than integers to refer to error codes as not to conflate the position of the error's description in the array (its index) with the error code. Additionally, if any unsuspecting developer uses array_merge to add their error codes to the array it will re-index the array and your error codes will change.
###Context
This filter is called every time wp_lib_error is called.
###Parameters
$errors
An array of all known errors that can occur in WP-Librarian
###Example
Suppose you want to add your own custom error to the error block reserved for plugins (1000+) and have chosen to use the range 2000-2099. If your custom error was error 2074 "++?????++ Out of Cheese Error. Redo From Start." then you would use the following code:
add_filter('wp_lib_error_codes', 'add_my_cheese_error');
function add_my_cheese_error($errors) {
$errors['2074'] = '++?????++ Out of Cheese Error. Redo From Start.';
return $errors;
}
Would generate the following error message if you used wp_lib_error(2074):
WP-Librarian Error 2074: ++?????++ Out of Cheese Error. Redo From Start.