Skip to content

Commit

Permalink
fix(TaskProcessingApi): Cleanup error handling
Browse files Browse the repository at this point in the history
Signed-off-by: provokateurin <kate@provokateurin.de>
  • Loading branch information
provokateurin committed May 16, 2024
1 parent 4c375c9 commit b15ff8b
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions core/Controller/TaskProcessingApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
use OCP\AppFramework\Http\Attribute\UserRateLimit;
use OCP\AppFramework\Http\DataDownloadResponse;
use OCP\AppFramework\Http\DataResponse;
use OCP\Common\Exception\NotFoundException;
use OCP\Files\File;
use OCP\Files\GenericFileException;
use OCP\Files\IRootFolder;
Expand Down Expand Up @@ -164,7 +163,7 @@ public function getTask(int $id): DataResponse {
return new DataResponse([
'task' => $json,
]);
} catch (NotFoundException $e) {
} catch (\OCP\TaskProcessing\Exception\NotFoundException $e) {
return new DataResponse(['message' => $this->l->t('Task not found')], Http::STATUS_NOT_FOUND);
} catch (\RuntimeException $e) {
return new DataResponse(['message' => $this->l->t('Internal error')], Http::STATUS_INTERNAL_SERVER_ERROR);
Expand Down Expand Up @@ -221,8 +220,6 @@ public function listTasksByApp(string $appId, ?string $customId = null): DataRes
]);
} catch (Exception $e) {
return new DataResponse(['message' => $this->l->t('Internal error')], Http::STATUS_INTERNAL_SERVER_ERROR);
} catch (\JsonException $e) {
return new DataResponse(['message' => $this->l->t('Internal error')], Http::STATUS_INTERNAL_SERVER_ERROR);
}
}

Expand Down Expand Up @@ -250,8 +247,6 @@ public function listTasks(?string $taskType, ?string $customId = null): DataResp
]);
} catch (Exception $e) {
return new DataResponse(['message' => $this->l->t('Internal error')], Http::STATUS_INTERNAL_SERVER_ERROR);
} catch (\JsonException $e) {
return new DataResponse(['message' => $this->l->t('Internal error')], Http::STATUS_INTERNAL_SERVER_ERROR);
}
}

Expand Down Expand Up @@ -287,7 +282,7 @@ public function getFileContents(int $taskId, int $fileId): Http\DataDownloadResp
return new Http\DataDownloadResponse($node->getContent(), $node->getName(), $node->getMimeType());
} catch (\OCP\TaskProcessing\Exception\NotFoundException $e) {
return new DataResponse(['message' => $this->l->t('Not found')], Http::STATUS_NOT_FOUND);
} catch (GenericFileException|NotPermittedException|LockedException|Exception $e) {
} catch (Exception $e) {
return new DataResponse(['message' => $this->l->t('Internal error')], Http::STATUS_INTERNAL_SERVER_ERROR);
}
}
Expand Down

0 comments on commit b15ff8b

Please sign in to comment.