forked from php-tmdb/api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exception_handling.php
42 lines (35 loc) · 1022 Bytes
/
exception_handling.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
/**
* This file is part of the Tmdb PHP API created by Michael Roterman.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package Tmdb
* @author Michael Roterman <[email protected]>
* @copyright (c) 2013, Michael Roterman
* @version 4.0.0
*/
header('Content-Type: text/html; charset=utf-8');
use Tmdb\Repository\MovieRepository;
use Tmdb\Exception\TmdbApiException;
require_once '../vendor/autoload.php';
require_once 'apikey.php';
/** @var Tmdb\Client $client **/
$client = require_once('setup-client.php');
$repository = new MovieRepository($client);
/**
* @var \Tmdb\Model\Movie $movie
*/
try {
$movie = $repository->load(298312000);
} catch (TmdbApiException $e) {
if (TmdbApiException::STATUS_RESOURCE_NOT_FOUND == $e->getCode()) {
// not found
echo $e->getMessage();
exit;
}
// catch other tmdb specific errors
} catch (Exception $e) {
// catch any other errors
}