Skip to content

Commit

Permalink
Added error page for viewing archives
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonmantank committed Feb 3, 2021
1 parent a293260 commit d62ae64
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Action/Archive/ViewAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace OTHelloWorld\Action\Archive;

use GuzzleHttp\Exception\ClientException;
use OpenTok\OpenTok;
use Psr\Container\ContainerInterface;
use Psr\Http\Message\ResponseInterface;
Expand Down Expand Up @@ -32,7 +33,14 @@ public function __construct(ContainerInterface $container)
*/
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, array $args) : ResponseInterface
{
$archive = $this->opentok->getArchive($args['archiveId']);
try {
$archive = $this->opentok->getArchive($args['archiveId']);
} catch (ClientException $e) {
return new HtmlResponse('<h1>Error</h1>'. $e->getMessage(), $e->getCode());
} catch (\Exception $e) {
return new HtmlResponse('<h1>Unknown Error</h1>'. $e->getMessage(), 500);
}

if ($archive->status=='available') {
return new RedirectResponse($archive->url);
}
Expand Down

0 comments on commit d62ae64

Please sign in to comment.