Skip to content

Commit

Permalink
Merge pull request #2 from MrMitch/exception-class
Browse files Browse the repository at this point in the history
Show the exception's class in the issue's text
  • Loading branch information
quentin-st committed Jul 17, 2016
2 parents fe4cb9e + 475b65a commit 8a3568a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions Resources/views/gitLabMessage.md.twig
Expand Up @@ -10,6 +10,7 @@ Logged-in user: {{ user }}

Exception in *[{{ file ~ '#' ~ line }}]({{ file ~ '#' ~ line }})*.

> {{ class }}
> {{ message }}

```
Expand Down
9 changes: 5 additions & 4 deletions Service/ExceptionLoggingService.php
Expand Up @@ -85,12 +85,14 @@ public function __construct($gitlabAPIUrl, $token, $project, $excludedEnvironmen

public function logException(GetResponseForExceptionEvent $event)
{
$exceptionInfos = $this->getExceptionInformation($event);

// Handle excluded environments
if (in_array($this->env, $this->excludedEnvironments))
return;

// Handle excluded exceptions
if (in_array(get_class($event->getException()), $this->excludedExceptions))
if (in_array($exceptionInfos['class'], $this->excludedExceptions))
return;

// Connect to GitLab's API
Expand All @@ -106,8 +108,6 @@ public function logException(GetResponseForExceptionEvent $event)
if ($project === null)
return;

$exceptionInfos = $this->getExceptionInformation($event);

$issue = $this->findIssue($exceptionInfos['title'], $project);
if (!$issue) {
// Issue does not exist yet, let's open it
Expand Down Expand Up @@ -229,7 +229,8 @@ private function getExceptionInformation(GetResponseForExceptionEvent $event)
'user' => $user,
'request' => $request,
'message' => $exception->getMessage(),
'stacktrace' => $exception->getTraceAsString()
'stacktrace' => $exception->getTraceAsString(),
'class' => get_class($exception)
];
}
}

0 comments on commit 8a3568a

Please sign in to comment.