key handling: add specific error codes

norefs