Skip to content

Commit 1ae94ab

Browse files
committed
Improve single message errors and testcase
1 parent 0e0265f commit 1ae94ab

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lib/Github/HttpClient/Plugin/GithubExceptionThrower.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ public function doHandleRequest(RequestInterface $request, callable $next, calla
8181
break;
8282

8383
default:
84+
if (is_string($error)) {
85+
$errors[] = $error;
86+
87+
break;
88+
}
89+
8490
if (isset($error['message'])) {
8591
$errors[] = $error['message'];
8692
}

test/Github/Tests/HttpClient/Plugin/GithubExceptionThrowerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function testHandleRequest(ResponseInterface $response, ExceptionInterfac
3737
if ($exception) {
3838
$this->expectException(get_class($exception));
3939
$this->expectExceptionCode($exception->getCode());
40-
$this->expectExceptionMessage($exception->getMessage());
40+
$this->expectExceptionMessageRegExp('/'.preg_quote($exception->getMessage(), '/').'$/');
4141
}
4242

4343
$plugin->doHandleRequest(
@@ -210,7 +210,7 @@ public static function responseProvider()
210210
]
211211
)
212212
),
213-
'exception' => new \Github\Exception\ValidationFailedException('Validation Failed', 422),
213+
'exception' => new \Github\Exception\ValidationFailedException('Validation Failed: We cannot delete an active deployment unless it is the only deployment in a given environment.', 422),
214214
],
215215
];
216216
}

0 commit comments

Comments
 (0)