Skip to content

Commit 8de6869

Browse files
committed
Catch \Throwable before \Exception
Some exceptions from PHP 7 are implementing \Throwable interface (see http://php.net/manual/en/language.errors.php7.php), so type/parse errors might not be caught with the current implementation. Since this library supports PHP 5, we can implement multiple `catch()` blocks without breaking changes. This PR makes sure that all kinds of errors & exceptions are caught, especially when getting authenticated user context from `FieldProvider` class.
1 parent b919041 commit 8de6869

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

src/Understand/UnderstandLaravel5/ExceptionEncoder.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ public function getCode($relativePath, $line, $linesAround = 6)
216216

217217
return $codeLines;
218218
}
219+
catch (\Throwable $e)
220+
{}
219221
catch (\Exception $e)
220222
{}
221223
}

src/Understand/UnderstandLaravel5/FieldProvider.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,8 @@ protected function getUserId()
431431
return $userId;
432432
}
433433
}
434+
catch (\Throwable $e)
435+
{}
434436
catch (\Exception $e)
435437
{}
436438

@@ -441,6 +443,8 @@ protected function getUserId()
441443
return $user->id;
442444
}
443445
}
446+
catch (\Throwable $e)
447+
{}
444448
catch (\Exception $e)
445449
{}
446450

@@ -451,6 +455,8 @@ protected function getUserId()
451455
return $user->id;
452456
}
453457
}
458+
catch (\Throwable $e)
459+
{}
454460
catch (\Exception $e)
455461
{}
456462
}

src/Understand/UnderstandLaravel5/Logger.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@ protected function send(array $event)
153153
{
154154
return $this->handler->handle($event);
155155
}
156+
catch (\Throwable $e)
157+
{
158+
return false;
159+
}
156160
catch (\Exception $ex)
157161
{
158162
return false;

0 commit comments

Comments
 (0)