Skip to content

Commit 9f5a0a7

Browse files
committed
add error handler
1 parent 9f04725 commit 9f5a0a7

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

solid/lib/Controller/SolidWebhookController.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace OCA\Solid\Controller;
44

5+
use Closure;
56
use OCA\Solid\AppInfo\Application;
67
use OCA\Solid\Service\SolidWebhookService;
78
use OCA\Solid\ServerConfig;
@@ -52,6 +53,7 @@ public function __construct($AppName, IRootFolder $rootFolder, IRequest $request
5253
try {
5354
$this->rawRequest = \Laminas\Diactoros\ServerRequestFactory::fromGlobals($_SERVER, $_GET, $_POST, $_COOKIE, $_FILES);
5455
$this->webId = $this->DPop->getWebId($this->rawRequest);
56+
// FIXME: Should we handle webhooks for 'public'?
5557
} catch(\Exception $e) {
5658
return new PlainResponse("Invalid token", 409);
5759
}
@@ -188,4 +190,13 @@ private function checkReadAccess($targetUrl) {
188190
}
189191
return true;
190192
}
193+
194+
private function handleNotFound(Closure $callback): DataResponse {
195+
try {
196+
return new DataResponse($callback());
197+
} catch (SolidWebhookNotFound $e) {
198+
$message = ['message' => $e->getMessage()];
199+
return new DataResponse($message, Http::STATUS_NOT_FOUND);
200+
}
201+
}
191202
}

0 commit comments

Comments
 (0)