File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -14,11 +14,14 @@ class RouteNotFoundException extends Exception
1414 /** @var int */
1515 protected $ code = 404 ;
1616
17- public function __construct (?string $ routeKey = null )
17+ public function __construct (?string $ routeKey = null , ? string $ message = null )
1818 {
1919 if ($ routeKey ) {
2020 $ this ->message = "Route not found: ' $ routeKey' " ;
2121 }
22+ if ($ message ) {
23+ $ this ->message = $ message ;
24+ }
2225
2326 parent ::__construct ($ this ->message , $ this ->code );
2427 }
Original file line number Diff line number Diff line change @@ -27,4 +27,13 @@ public function test_it_throws_an_exception_when_page_type_is_not_supported()
2727
2828 throw new RouteNotFoundException ('not-found ' );
2929 }
30+
31+ public function test_it_throws_an_exception_with_custom_message ()
32+ {
33+ $ this ->expectException (RouteNotFoundException::class);
34+ $ this ->expectExceptionMessage ('Custom message ' );
35+ $ this ->expectExceptionCode (404 );
36+
37+ throw new RouteNotFoundException (null , 'Custom message ' );
38+ }
3039}
You can’t perform that action at this time.
0 commit comments