Skip to content

Commit

Permalink
Fix SoapFault detail with nested object
Browse files Browse the repository at this point in the history
Fixes #1431
  • Loading branch information
neclimdul committed May 15, 2020
1 parent 56a8b31 commit 2066ce8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/Monolog/Formatter/LineFormatter.php
Expand Up @@ -180,8 +180,13 @@ private function formatException(\Throwable $e): string
$str .= ' faultactor: ' . $e->faultactor;
}

if (isset($e->detail) && (is_string($e->detail) || is_object($e->detail) || is_array($e->detail))) {
$str .= ' detail: ' . (is_string($e->detail) ? $e->detail : reset($e->detail));
if (isset($e->detail)) {
if (is_string($e->detail)) {
$str .= ' detail: ' . $e->detail;
}
elseif (is_object($e->detail) || is_array($e->detail)) {
$str .= ' detail: ' . Utils::jsonEncode($e->detail);
}
}
}
$str .= '): ' . $e->getMessage() . ' at ' . $e->getFile() . ':' . $e->getLine() . ')';
Expand Down
9 changes: 7 additions & 2 deletions src/Monolog/Formatter/NormalizerFormatter.php
Expand Up @@ -202,8 +202,13 @@ protected function normalizeException(Throwable $e, int $depth = 0)
$data['faultactor'] = $e->faultactor;
}

if (isset($e->detail) && (is_string($e->detail) || is_object($e->detail) || is_array($e->detail))) {
$data['detail'] = is_string($e->detail) ? $e->detail : reset($e->detail);
if (isset($e->detail)) {
if (is_string($e->detail)) {
$data['detail'] = $e->detail;
}
elseif (is_object($e->detail) || is_array($e->detail)) {
$data['detail'] = Utils::jsonEncode($e->detail);
}
}
}

Expand Down

0 comments on commit 2066ce8

Please sign in to comment.