24 lines
467 B
PHP
24 lines
467 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace OCA\RePod\Controller;
|
|
|
|
use Closure;
|
|
|
|
use OCA\RePod\Service\NoteNotFound;
|
|
use OCP\AppFramework\Http;
|
|
|
|
use OCP\AppFramework\Http\DataResponse;
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|