Nextcloud-App/lib/Controller/Errors.php

22 lines
453 B
PHP
Raw Normal View History

<?php
2021-08-21 14:25:23 +00:00
namespace OCA\UPschooling\Controller;
use Closure;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
2021-08-21 14:25:23 +00:00
use OCA\UPschooling\Service\NoteNotFound;
trait Errors {
protected function handleNotFound(Closure $callback): DataResponse {
try {
return new DataResponse($callback());
} catch (NoteNotFound $e) {
$message = ['message' => $e->getMessage()];
return new DataResponse($message, Http::STATUS_NOT_FOUND);
}
}
}