Skip to content

Commit

Permalink
代码改进,cookie context decode失败后,记录日志而非抛出异常
Browse files Browse the repository at this point in the history
  • Loading branch information
yeaha committed Mar 22, 2017
1 parent 0b27bee commit 3eb554b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Context/Cookie.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,18 @@ protected function decode($string)
break;
}

return \Owl\safe_json_decode($string, true) ?: [];
try {
return \Owl\safe_json_decode($string, true) ?: [];
} catch (\Exception $exception) {
if (DEBUG) {
throw $exception;
}

\Owl\Logger::log('error', 'cookie context json decode failed', [
'message' => $exception->getMessage(),
'code' => $exception->getCode(),
]);
}
} while (false);

return [];
Expand Down

0 comments on commit 3eb554b

Please # to comment.