2021-08-21 14:17:14 +00:00
|
|
|
<?php
|
|
|
|
|
2021-08-21 14:25:23 +00:00
|
|
|
namespace OCA\UPschooling\Controller;
|
2021-08-21 14:17:14 +00:00
|
|
|
|
|
|
|
use Closure;
|
2022-04-23 14:55:05 +00:00
|
|
|
use OCA\UPschooling\Exceptions\RoomNotFoundException;
|
2021-10-10 17:01:00 +00:00
|
|
|
use OCA\UPschooling\Exceptions\TicketNotFoundException;
|
2021-08-21 14:17:14 +00:00
|
|
|
use OCP\AppFramework\Http;
|
|
|
|
use OCP\AppFramework\Http\DataResponse;
|
|
|
|
|
|
|
|
trait Errors {
|
|
|
|
protected function handleNotFound(Closure $callback): DataResponse {
|
|
|
|
try {
|
|
|
|
return new DataResponse($callback());
|
2022-04-23 14:55:05 +00:00
|
|
|
} catch (TicketNotFoundException|RoomNotFoundException $e) {
|
|
|
|
$result = $e->getResult();
|
|
|
|
return new DataResponse($result->getMeta(), $result->getStatusCode());
|
2021-08-21 14:17:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|