make sure not to write past the k_error buffer