Skip to content
Browse files

Correct stacktrace behavior

  • Loading branch information...
1 parent e203918 commit d085ed1ddd10199b8398744ac31c6a552f2eaaec @dcramer dcramer committed Aug 24, 2012
Showing with 15 additions and 13 deletions.
  1. +15 −13 lib/Raven/Client.php
View
28 lib/Raven/Client.php
@@ -219,20 +219,22 @@ public function capture($data, $stack)
array_shift($stack);
}
- /**
- * PHP's way of storing backstacks seems bass-ackwards to me
- * 'function' is not the function you're in; it's any function being
- * called, so we have to shift 'function' down by 1. Ugh.
- */
- for ($i = 0; $i < count($stack) - 1; $i++) {
- $stack[$i]['function'] = $stack[$i + 1]['function'];
- }
- $stack[count($stack) - 1]['function'] = null;
+ if (!empty($stack)) {
+ /**
+ * PHP's way of storing backstacks seems bass-ackwards to me
+ * 'function' is not the function you're in; it's any function being
+ * called, so we have to shift 'function' down by 1. Ugh.
+ */
+ for ($i = 0; $i < count($stack) - 1; $i++) {
+ $stack[$i]['function'] = $stack[$i + 1]['function'];
+ }
+ $stack[count($stack) - 1]['function'] = null;
- if ($stack && !isset($data['sentry.interfaces.Stacktrace'])) {
- $data['sentry.interfaces.Stacktrace'] = array(
- 'frames' => Raven_Stacktrace::get_stack_info($stack)
- );
+ if (!isset($data['sentry.interfaces.Stacktrace'])) {
+ $data['sentry.interfaces.Stacktrace'] = array(
+ 'frames' => Raven_Stacktrace::get_stack_info($stack)
+ );
+ }
}
if (function_exists('mb_convert_encoding')) {

0 comments on commit d085ed1

Please sign in to comment.
Something went wrong with that request. Please try again.