/// <summary> /// Update KeyValue only if specific key already exist. /// Return error message if not. /// </summary> private CommandResult Update(string key, string value) { try { if (key is null || key.Trim().Length == 0) { throw new ArgumentNullException("key"); } if (value is null) { throw new ArgumentNullException("value"); } _store.UpdateValue(key, value); } catch (KeyNotFoundInRepositoryException) { return(new FailureResult { ErrorMessage = "key not found" }); } catch (ArgumentNullException e) { return(new FailureResult { ErrorMessage = e.ParamName + " is required" }); } return(new SuccessResult()); }