|
3 | 3 | use Backpack\Basset\Facades\Basset; |
4 | 4 | use Creativeorange\Gravatar\Facades\Gravatar; |
5 | 5 | use Illuminate\Support\Facades\Log; |
| 6 | +use Illuminate\Support\Str; |
6 | 7 |
|
7 | 8 | if (! function_exists('backpack_url')) { |
8 | 9 | /** |
@@ -256,15 +257,23 @@ function backpack_view($view) |
256 | 257 | } |
257 | 258 | } |
258 | 259 |
|
259 | | - // we only run the back trace in case we couldn't find the view |
260 | | - // and help developer understand where is the error |
261 | | - $backtrace = env('APP_ENV') !== 'production' && env('APP_DEBUG') ? debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1) : []; |
| 260 | + $errorMessage = 'The view: ['.$view.'] was not found in any of the following view paths: ['.implode(' ], [ ', $viewPaths).']'; |
262 | 261 |
|
263 | | - $functionCaller = $backtrace[0] ?? []; |
264 | | - $functionLine = $functionCaller['line'] ?? 'N/A'; |
265 | | - $functionFile = $functionCaller['file'] ?? 'N/A'; |
| 262 | + $errorDetails = (function() { |
| 263 | + if (env('APP_ENV') === 'production' || !env('APP_DEBUG')) { |
| 264 | + return ''; |
| 265 | + } |
| 266 | + |
| 267 | + $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2) ?? []; |
| 268 | + $functionCaller = $backtrace[1] ?? []; |
| 269 | + $functionLine = $functionCaller['line'] ?? 'N/A'; |
| 270 | + $functionFile = $functionCaller['file'] ?? 'N/A'; |
266 | 271 |
|
267 | | - abort(500, 'The view: ['.$view.'] was not found in any of the following view paths: ['.implode(' ], [ ', $viewPaths).'] - called on: '.$functionFile.' on line: '.$functionLine); |
| 272 | + return '- Called in: '.Str::after($functionFile, base_path()).' on line: '.$functionLine; |
| 273 | + })(); |
| 274 | + |
| 275 | + |
| 276 | + abort(500, $errorMessage.$errorDetails); |
268 | 277 | } |
269 | 278 | } |
270 | 279 |
|
|
0 commit comments