2020-04-26 11:36:41 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace OCA\BigBlueButton\Controller;
|
|
|
|
|
|
|
|
use Closure;
|
2020-06-15 17:23:53 +02:00
|
|
|
use Exception;
|
2020-04-26 11:36:41 +02:00
|
|
|
use OCP\AppFramework\Http;
|
|
|
|
use OCP\AppFramework\Http\DataResponse;
|
|
|
|
|
|
|
|
use OCA\BigBlueButton\Service\RoomNotFound;
|
2020-06-15 17:23:53 +02:00
|
|
|
use OCA\BigBlueButton\Service\RoomShareNotFound;
|
2020-04-26 11:36:41 +02:00
|
|
|
|
|
|
|
trait Errors
|
|
|
|
{
|
|
|
|
protected function handleNotFound(Closure $callback): DataResponse
|
|
|
|
{
|
|
|
|
try {
|
2020-06-15 17:23:53 +02:00
|
|
|
$return = $callback();
|
|
|
|
return ($return instanceof DataResponse) ? $return : new DataResponse($return);
|
|
|
|
} catch (Exception $e) {
|
|
|
|
if ($e instanceof RoomNotFound ||
|
|
|
|
$e instanceof RoomShareNotFound) {
|
|
|
|
$message = ['message' => $e->getMessage()];
|
|
|
|
return new DataResponse($message, Http::STATUS_NOT_FOUND);
|
|
|
|
}
|
|
|
|
|
|
|
|
throw $e;
|
2020-04-26 11:36:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|