Skip to content

Commit

Permalink
fix: removed error method and call Logger error directly in case of e…
Browse files Browse the repository at this point in the history
…xception

Signed-off-by: yemkareems <yemkareems@gmail.com>
  • Loading branch information
yemkareems committed Apr 29, 2024
1 parent 45b874d commit 6ed0835
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions apps/admin_audit/lib/Actions/Files.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ public function read(BeforeNodeReadEvent $event): void {
'path' => mb_substr($event->getNode()->getInternalPath(), 5),
];
} catch (InvalidPathException|NotFoundException $e) {
$this->error("Exception thrown in file read: ".$e->getMessage());
\OCP\Server::get(LoggerInterface::class)->error(
"Exception thrown in file read: ".$e->getMessage(), ['app' => 'admin_audit']
);
return;
}
$this->log(
Expand All @@ -84,7 +86,9 @@ public function rename(NodeRenamedEvent $event): void {
'newpath' => mb_substr($target->getPath(), 5),
];
} catch (InvalidPathException|NotFoundException $e) {
$this->error("Exception thrown in file rename: ".$e->getMessage());
\OCP\Server::get(LoggerInterface::class)->error(
"Exception thrown in file rename: ".$e->getMessage(), ['app' => 'admin_audit']
);
return;
}

Expand All @@ -107,7 +111,9 @@ public function create(NodeCreatedEvent $event): void {
'path' => mb_substr($event->getNode()->getInternalPath(), 5),
];
} catch (InvalidPathException|NotFoundException $e) {
$this->error("Exception thrown in file create: ".$e->getMessage());
\OCP\Server::get(LoggerInterface::class)->error(
"Exception thrown in file create: ".$e->getMessage(), ['app' => 'admin_audit']
);
return;
}
if ($params['path'] === '/' || $params['path'] === '') {
Expand All @@ -134,7 +140,9 @@ public function copy(NodeCopiedEvent $event): void {
'newpath' => mb_substr($event->getTarget()->getInternalPath(), 5),
];
} catch (InvalidPathException|NotFoundException $e) {
$this->error("Exception thrown in file copy: ".$e->getMessage());
\OCP\Server::get(LoggerInterface::class)->error(
"Exception thrown in file copy: ".$e->getMessage(), ['app' => 'admin_audit']
);
return;
}
$this->log(
Expand All @@ -156,7 +164,9 @@ public function write(BeforeNodeWrittenEvent $event): void {
'path' => mb_substr($event->getNode()->getInternalPath(), 5),
];
} catch (InvalidPathException|NotFoundException $e) {
$this->error("Exception thrown in file write: ".$e->getMessage());
\OCP\Server::get(LoggerInterface::class)->error(
"Exception thrown in file write: ".$e->getMessage(), ['app' => 'admin_audit']
);
return;
}
if ($params['path'] === '/' || $params['path'] === '') {
Expand All @@ -182,7 +192,9 @@ public function update(NodeWrittenEvent $event): void {
'path' => mb_substr($event->getNode()->getInternalPath(), 5),
];
} catch (InvalidPathException|NotFoundException $e) {
$this->error("Exception thrown in file update: ".$e->getMessage());
\OCP\Server::get(LoggerInterface::class)->error(
"Exception thrown in file update: ".$e->getMessage(), ['app' => 'admin_audit']
);
return;
}
$this->log(
Expand All @@ -204,7 +216,9 @@ public function delete(NodeDeletedEvent $event): void {
'path' => mb_substr($event->getNode()->getInternalPath(), 5),
];
} catch (InvalidPathException|NotFoundException $e) {
$this->error("Exception thrown in file delete: ".$e->getMessage());
\OCP\Server::get(LoggerInterface::class)->error(
"Exception thrown in file delete: ".$e->getMessage(), ['app' => 'admin_audit']
);
return;
}
$this->log(
Expand All @@ -231,7 +245,9 @@ public function preview(BeforePreviewFetchedEvent $event): void {
'path' => mb_substr($file->getInternalPath(), 5)
];
} catch (InvalidPathException|NotFoundException $e) {
$this->error("Exception thrown in file preview: ".$e->getMessage());
\OCP\Server::get(LoggerInterface::class)->error(
"Exception thrown in file preview: ".$e->getMessage(), ['app' => 'admin_audit']
);
return;
}
$this->log(
Expand All @@ -240,14 +256,4 @@ public function preview(BeforePreviewFetchedEvent $event): void {
array_keys($params)
);
}

/**
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function error(string $message): void {
\OCP\Server::get(LoggerInterface::class)->error(
$message, ['app' => 'admin_audit']
);
}
}

0 comments on commit 6ed0835

Please sign in to comment.