state/apiserver: fix sprintf, log errors

Log errors in sendError functions, and
change signature to not return error.