mirror of
https://github.com/LibreSign/libresign.git
synced 2025-12-18 05:20:45 +01:00
22 lines
561 B
PHP
22 lines
561 B
PHP
<?php
|
|
|
|
namespace OCA\Signer\Controller;
|
|
|
|
use OCA\Signer\Exception\SignerException;
|
|
use OCP\AppFramework\Http;
|
|
use OCP\AppFramework\Http\DataResponse;
|
|
|
|
trait HandleErrorsTrait
|
|
{
|
|
protected function handleErrors(\Exception $exception): DataResponse
|
|
{
|
|
if ($exception instanceof SignerException) {
|
|
return new DataResponse($exception->jsonSerialize(), $exception->getCode());
|
|
}
|
|
|
|
return new DataResponse(
|
|
['message' => $exception->getMessage()],
|
|
Http::STATUS_INTERNAL_SERVER_ERROR
|
|
);
|
|
}
|
|
}
|