File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
src/DebugBar/DataCollector Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -69,15 +69,20 @@ public function collect()
6969 */
7070 public function formatExceptionData (Exception $ e )
7171 {
72- $ lines = file ($ e ->getFile ());
73- $ start = $ e ->getLine () - 4 ;
74- $ lines = array_slice ($ lines , $ start < 0 ? 0 : $ start , 7 );
72+ $ filePath = $ e ->getFile ();
73+ if ($ filePath && file_exists ($ filePath )) {
74+ $ lines = file ($ filePath );
75+ $ start = $ e ->getLine () - 4 ;
76+ $ lines = array_slice ($ lines , $ start < 0 ? 0 : $ start , 7 );
77+ } else {
78+ $ lines = array ("Cannot open the file ( $ filePath) in which the exception occurred " );
79+ }
7580
7681 return array (
7782 'type ' => get_class ($ e ),
7883 'message ' => $ e ->getMessage (),
7984 'code ' => $ e ->getCode (),
80- 'file ' => $ e -> getFile () ,
85+ 'file ' => $ filePath ,
8186 'line ' => $ e ->getLine (),
8287 'surrounding_lines ' => $ lines
8388 );
You can’t perform that action at this time.
0 commit comments