about summary refs log tree commit diff stats
path: root/classes
diff options
context:
space:
mode:
authorAndrew Dolgov <fox@fakecake.org>2026-05-27 22:24:45 +0300
committerAndrew Dolgov <fox@fakecake.org>2026-05-27 22:24:45 +0300
commit69b46e2fd39294d347206edd8b4ea01b749bdb51 (patch)
tree2425f9aadac012bc8f39a16ecf52af16c074f43b /classes
parent8d22861efda3b41e5fffce8b12638019b438587c (diff)
downloadthe-epube-69b46e2fd39294d347206edd8b4ea01b749bdb51.tar.gz
the-epube-69b46e2fd39294d347206edd8b4ea01b749bdb51.tar.xz
update some error messages, add tests for cover
Diffstat (limited to 'classes')
-rw-r--r--classes/Handler/CoverHandler.php4
-rw-r--r--classes/Handler/DownloadHandler.php2
-rw-r--r--classes/Handler/LastreadHandler.php4
-rw-r--r--classes/Handler/LoginHandler.php2
-rw-r--r--classes/Handler/PaginationHandler.php6
-rw-r--r--classes/Router.php2
6 files changed, 10 insertions, 10 deletions
diff --git a/classes/Handler/CoverHandler.php b/classes/Handler/CoverHandler.php
index d4c0a2c..357c415 100644
--- a/classes/Handler/CoverHandler.php
+++ b/classes/Handler/CoverHandler.php
@@ -31,12 +31,12 @@ class CoverHandler implements RequestHandlerInterface, AuthRequired
 			} else {
 				return (new Response())
 					->withStatus(404)
-					->withBody("File not found.");
+					->withBody(json_encode(["error" => "Not found."]));
 			}
 		}
 
 		return (new Response())
 			->withStatus(404)
-			->withBody("File not found.");
+			->withBody(json_encode(["error" => "Not found."]));
 	}
 }
diff --git a/classes/Handler/DownloadHandler.php b/classes/Handler/DownloadHandler.php
index 6eaca11..bf450e0 100644
--- a/classes/Handler/DownloadHandler.php
+++ b/classes/Handler/DownloadHandler.php
@@ -31,6 +31,6 @@ class DownloadHandler implements RequestHandlerInterface, AuthRequired
 
 		return (new Response())
 			->withStatus(404)
-			->withBody("File not found.");
+			->withBody(json_encode(["error" => "Not found."]));
 	}
 }
diff --git a/classes/Handler/LastreadHandler.php b/classes/Handler/LastreadHandler.php
index e4ea81b..cdaade0 100644
--- a/classes/Handler/LastreadHandler.php
+++ b/classes/Handler/LastreadHandler.php
@@ -30,7 +30,7 @@ class LastreadHandler implements RequestHandlerInterface, AuthRequired
 
 		return (new Response())
 			->withStatus(404)
-			->withBody("Not found.");
+			->withBody(json_encode(["error" => "Not found."]));
 	}
 
 	private function handleStore(int $bookid, int $page, string $cfi, int $timestamp): Response
@@ -79,7 +79,7 @@ class LastreadHandler implements RequestHandlerInterface, AuthRequired
 				(string) $request->getAttribute('cfi', ''),
 				(int) $request->getAttribute('timestamp'),
 			),
-			default          => (new Response())->withStatus(404)->withBody("Not found."),
+			default          => (new Response())->withStatus(404)->withBody(json_encode(["error" => "Not found."])),
 		};
 	}
 }
diff --git a/classes/Handler/LoginHandler.php b/classes/Handler/LoginHandler.php
index e94c2c9..9064bbb 100644
--- a/classes/Handler/LoginHandler.php
+++ b/classes/Handler/LoginHandler.php
@@ -173,6 +173,6 @@ class LoginHandler implements RequestHandlerInterface
 
 		return (new Response())
 			->withStatus(404)
-			->withBody("Not found.");
+			->withBody(json_encode(["error" => "Not found."]));
 	}
 }
diff --git a/classes/Handler/PaginationHandler.php b/classes/Handler/PaginationHandler.php
index 7015dfc..54421d5 100644
--- a/classes/Handler/PaginationHandler.php
+++ b/classes/Handler/PaginationHandler.php
@@ -24,7 +24,7 @@ class PaginationHandler implements RequestHandlerInterface, AuthRequired
 
 		return (new Response())
 			->withStatus(404)
-			->withBody("File not found.");
+			->withBody(json_encode(["error" => "File not found."]));
 	}
 
 	private function handleStore(int $bookid, ?string $payload): Response
@@ -62,7 +62,7 @@ class PaginationHandler implements RequestHandlerInterface, AuthRequired
 
 		return (new Response())
 			->withStatus(404)
-			->withBody("Not found.");
+			->withBody(json_encode(["error" => "Not found."]));
 	}
 
 	public function handle(Request $request): Response
@@ -74,7 +74,7 @@ class PaginationHandler implements RequestHandlerInterface, AuthRequired
 			'getpagination'   => $this->handleGet($bookid),
 			'storepagination' => $this->handleStore($bookid, $request->getAttribute('payload')),
 			'deletepagination' => $this->handleDelete($bookid),
-			default           => (new Response())->withStatus(404)->withBody("Not found."),
+			default           => (new Response())->withStatus(404)->withBody(json_encode(["error" => "Not found."])),
 		};
 	}
 }
diff --git a/classes/Router.php b/classes/Router.php
index 79882ce..bae01ec 100644
--- a/classes/Router.php
+++ b/classes/Router.php
@@ -25,7 +25,7 @@ class Router
 		if (!$handler) {
 			$response = (new Response())
 				->withStatus(404)
-				->withBody("Method not found.");
+				->withBody(json_encode(["error" => "Method not found"]));
 			$response->send();
 			exit;
 		}