1616 */
1717namespace modethirteen \FluentCache ;
1818
19+ use Exception ;
1920use Psr \EventDispatcher \StoppableEventInterface ;
2021use Psr \SimpleCache \CacheException ;
2122use Psr \SimpleCache \CacheInterface ;
@@ -25,12 +26,10 @@ class Event extends \Symfony\Contracts\EventDispatcher\Event implements Stoppabl
2526 const CACHE_GET_ERROR = 'cache:get.error ' ;
2627 const CACHE_GET_HIT = 'cache:get.hit ' ;
2728 const CACHE_GET_MISS = 'cache:get.miss ' ;
28- const CACHE_VALIDATION_SUCCESS = 'cache:validation.success ' ;
29- const CACHE_VALIDATION_FAIL = 'cache:validation.fail ' ;
3029 const BUILD_START = 'build:start ' ;
31- const BUILD_STOP = 'build:stop ' ;
32- const BUILD_VALIDATION_SUCCESS = 'build:validation. success ' ;
33- const BUILD_VALIDATION_FAIL = 'build:validation. fail ' ;
30+ const BUILD_ERROR = 'build:error ' ;
31+ const BUILD_SUCCESS = 'build:success ' ;
32+ const BUILD_FAIL = 'build:fail ' ;
3433 const CACHE_SET_START = 'cache:set.start ' ;
3534 const CACHE_SET_ERROR = 'cache:set.error ' ;
3635 const CACHE_SET_SUCCESS = 'cache:set.success ' ;
@@ -46,10 +45,15 @@ class Event extends \Symfony\Contracts\EventDispatcher\Event implements Stoppabl
4645 */
4746 private $ cacheType = null ;
4847
48+ /**
49+ * @var Exception|null
50+ */
51+ private $ buildException = null ;
52+
4953 /**
5054 * @var CacheException|null
5155 */
52- private $ exception = null ;
56+ private $ cacheException = null ;
5357
5458 /**
5559 * @var string
@@ -63,6 +67,13 @@ public function __construct(string $message) {
6367 $ this ->message = $ message ;
6468 }
6569
70+ /**
71+ * @return Exception|null
72+ */
73+ public function getBuildException () : ?Exception {
74+ return $ this ->buildException ;
75+ }
76+
6677 /**
6778 * @return string|null
6879 */
@@ -80,8 +91,8 @@ public function getCacheType() : ?string {
8091 /**
8192 * @return CacheException|null
8293 */
83- public function getException () : ?CacheException {
84- return $ this ->exception ;
94+ public function getCacheException () : ?CacheException {
95+ return $ this ->cacheException ;
8596 }
8697
8798 /**
@@ -91,6 +102,16 @@ public function getMessage() : string {
91102 return $ this ->message ;
92103 }
93104
105+ /**
106+ * @param Exception $e
107+ * @return static
108+ */
109+ public function withBuildException (Exception $ e ) : object {
110+ $ event = clone $ this ;
111+ $ event ->buildException = $ e ;
112+ return $ event ;
113+ }
114+
94115 /**
95116 * @param CacheInterface $cache
96117 * @param string|null $key
@@ -107,9 +128,9 @@ public function withCache(CacheInterface $cache, ?string $key = null) : object {
107128 * @param CacheException $e
108129 * @return static
109130 */
110- public function withException (CacheException $ e ) : object {
131+ public function withCacheException (CacheException $ e ) : object {
111132 $ event = clone $ this ;
112- $ event ->exception = $ e ;
133+ $ event ->cacheException = $ e ;
113134 return $ event ;
114135 }
115136}
0 commit comments