aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-04-17 17:41:46 +0000
committerFuwn <[email protected]>2026-04-17 17:42:34 +0000
commit3441a0f2fbb19461039ce16a0387c8d02da08bf0 (patch)
treea88694c02ba5173dd328e6e4fd3cdf4a565a718a
parentchore(.gitignore): Ignore macOS .DS_Store files (diff)
downloadmayu-3441a0f2fbb19461039ce16a0387c8d02da08bf0.tar.xz
mayu-3441a0f2fbb19461039ce16a0387c8d02da08bf0.zip
refactor: Tighten dead branches and fail fast on missing index.html
-rw-r--r--src/database.gleam14
-rw-r--r--src/mayu.gleam11
2 files changed, 5 insertions, 20 deletions
diff --git a/src/database.gleam b/src/database.gleam
index 07264fd..5c3d9b2 100644
--- a/src/database.gleam
+++ b/src/database.gleam
@@ -64,18 +64,8 @@ pub fn get_counter(connection, name) {
option.unwrap(row.2, ""),
option.unwrap(row.3, ""),
))
- Ok([]) -> {
- wisp.log_error("Database query returned no rows unexpectedly.")
-
- Error("Unreachable entity")
- }
- Ok([_, _, ..]) -> {
- wisp.log_error("Database query returned multiple rows unexpectedly.")
-
- Error("Unreachable entity")
- }
- Error(_) -> {
- wisp.log_error("Database query failed.")
+ _ -> {
+ wisp.log_error("Database query failed or returned unexpected rows.")
Error("Database operation failed")
}
diff --git a/src/mayu.gleam b/src/mayu.gleam
index 441887d..bb05b77 100644
--- a/src/mayu.gleam
+++ b/src/mayu.gleam
@@ -18,14 +18,9 @@ pub fn main() {
Ok(version) -> "(v" <> version <> ")"
Error(_) -> ""
}
- let index_html = case simplifile.read("index.html") {
- Ok(content) -> string.replace(content, "{{ MAYU_VERSION }}", version_tag)
- Error(_) -> {
- wisp.log_error("Failed to read index.html")
-
- ""
- }
- }
+ let assert Ok(index_html_source) = simplifile.read("index.html")
+ let index_html =
+ string.replace(index_html_source, "{{ MAYU_VERSION }}", version_tag)
use connection <- sqlight.with_connection("./data/count.db")