@@ -97,8 +97,8 @@ public function handle(
9797 . DIRECTORY_SEPARATOR . 'errors ' . DIRECTORY_SEPARATOR . $ addPath ;
9898
9999 // Determine the views
100- $ view = $ this ->determineView ($ exception , $ path );
101- $ altView = $ this ->determineView ($ exception , $ altPath );
100+ $ view = $ this ->determineView ($ exception , $ path, $ statusCode );
101+ $ altView = $ this ->determineView ($ exception , $ altPath, $ statusCode );
102102
103103 // Check if the view exists
104104 $ viewFile = null ;
@@ -119,13 +119,16 @@ public function handle(
119119 }
120120
121121 /**
122- * Determines the view to display based on the exception thrown,
123- * whether an HTTP or CLI request, etc.
122+ * Determines the view to display based on the exception thrown, HTTP status
123+ * code, whether an HTTP or CLI request, etc.
124124 *
125125 * @return string The filename of the view file to use
126126 */
127- protected function determineView (Throwable $ exception , string $ templatePath ): string
128- {
127+ protected function determineView (
128+ Throwable $ exception ,
129+ string $ templatePath ,
130+ int $ statusCode = 500
131+ ): string {
129132 // Production environments should have a custom exception file.
130133 $ view = 'production.php ' ;
131134
@@ -147,8 +150,8 @@ protected function determineView(Throwable $exception, string $templatePath): st
147150 $ templatePath = rtrim ($ templatePath , '\\/ ' ) . DIRECTORY_SEPARATOR ;
148151
149152 // Allow for custom views based upon the status code
150- if (is_file ($ templatePath . 'error_ ' . $ exception -> getCode () . '.php ' )) {
151- return 'error_ ' . $ exception -> getCode () . '.php ' ;
153+ if (is_file ($ templatePath . 'error_ ' . $ statusCode . '.php ' )) {
154+ return 'error_ ' . $ statusCode . '.php ' ;
152155 }
153156
154157 return $ view ;
0 commit comments