Skip to content

Commit

Permalink
(#13) Better exception messages when deleting
Browse files Browse the repository at this point in the history
  • Loading branch information
mecha committed Jul 8, 2020
1 parent decd3e3 commit 3b702ae
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/CachePool.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ public function delete($key)
try {
$this->deleteTransient($key);
} catch (Exception $e) {
throw new CacheException(sprintf('Could not delete cache for key "%1$s"', $origKey), 0, $e);
$message = sprintf('Failed to delete cache for key "%1$s": %2$s', $origKey, $e->getMessage());
throw new CacheException($message, 0, $e);
}

return true;
Expand Down Expand Up @@ -359,7 +360,7 @@ protected function getOptionOriginal(string $key, $default = null)
protected function deleteTransient(string $key): void
{
if (!delete_transient($key)) {
throw new RuntimeException(sprintf('Could not delete transient for key "%1$s"', $key));
throw new RuntimeException(sprintf('delete_transient() failed for key "%1$s"', $key));
}
}

Expand Down

0 comments on commit 3b702ae

Please sign in to comment.