Skip to content

Commit 89ae52e

Browse files
authored
Added error handling with the _HANDLER string (#73)
1 parent 45f4631 commit 89ae52e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/bref/src/Runtime.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,11 @@ public function getRunner(?object $application): RunnerInterface
4040
}
4141

4242
if ($application instanceof ContainerInterface) {
43-
$handler = getenv('_HANDLER');
44-
// TODO error checking
45-
[$script, $service] = explode(':', $handler);
46-
$application = $application->get($service);
43+
$handler = explode(':', $_SERVER['_HANDLER']);
44+
if (!isset($handler[1]) || '' === $handler[1]) {
45+
throw new \RuntimeException(sprintf('Application is instance of ContainerInterface but the handler does not contain a service. The handler must be on format "path/to/file.php:App\\Lambda\\MyHandler". You provided "%s".', $_SERVER['_HANDLER']));
46+
}
47+
$application = $application->get($handler[1]);
4748
}
4849

4950
if ($application instanceof Handler) {

0 commit comments

Comments
 (0)