Controller::API() returns null on error, so we can return 404 instead of 500.
This commit is contained in:
@@ -120,8 +120,9 @@ class Controller extends BaseController
|
|||||||
. 'X-User-Agent: ' . request()->server('HTTP_USER_AGENT') . "\r\n"
|
. 'X-User-Agent: ' . request()->server('HTTP_USER_AGENT') . "\r\n"
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
//\dump($http_response_header);
|
||||||
return json_decode(file_get_contents($this->API_URL . $url, false, stream_context_create($arrContextOptions)));
|
$result = @file_get_contents($this->API_URL . $url, false, stream_context_create($arrContextOptions));
|
||||||
|
return $result ? json_decode($result) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function checkAPI($url)
|
protected function checkAPI($url)
|
||||||
|
|||||||
@@ -49,7 +49,10 @@ class RadioController extends Controller
|
|||||||
|
|
||||||
public function program($id)
|
public function program($id)
|
||||||
{
|
{
|
||||||
$apiResult = $this->API('programma/details/' . (int)$id);
|
$apiResult = $this->API('programma/details/' . (int)$id);
|
||||||
|
if($apiResult == null) {
|
||||||
|
return abort(404);
|
||||||
|
}
|
||||||
return view('radioprogram', ['program' => new \Model\Program($apiResult)]);
|
return view('radioprogram', ['program' => new \Model\Program($apiResult)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user