⭐ Moe-Counter Compatible Website Hit Counter Written in Gleam mayu.due.moe
hit-counter svg moe
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat(cache): Add error logs

Fuwn 8b2e5778 07ed2a89

+30 -16
+30 -16
src/cache.gleam
··· 5 5 import gleam/result 6 6 import image 7 7 import simplifile 8 + import wisp 8 9 9 10 pub type CachedImage { 10 11 CachedImage(data: BitArray, info: image.ImageInformation) ··· 17 18 list.fold( 18 19 case simplifile.read_directory("./themes") { 19 20 Ok(files) -> files 20 - Error(_) -> [] 21 + Error(_) -> { 22 + wisp.log_error("Error reading themes directory") 23 + 24 + [] 25 + } 21 26 }, 22 27 dict.new(), 23 28 fn(accumulated_themes, theme) { ··· 26 31 theme, 27 32 list.range(0, 9) 28 33 |> list.fold(dict.new(), fn(accumulated_digits, digit) { 29 - case 30 - simplifile.read_bits( 31 - from: "./themes/" 32 - <> theme 33 - <> "/" 34 - <> int.to_string(digit) 35 - <> "." 36 - <> case theme { 37 - "gelbooru-h" | "moebooru-h" | "lain" | "garukura" -> "png" 38 - _ -> "gif" 39 - }, 40 - ) 41 - { 34 + let path = 35 + "./themes/" 36 + <> theme 37 + <> "/" 38 + <> int.to_string(digit) 39 + <> "." 40 + <> case theme { 41 + "gelbooru-h" | "moebooru-h" | "lain" | "garukura" -> "png" 42 + _ -> "gif" 43 + } 44 + 45 + case simplifile.read_bits(from: path) { 42 46 Ok(image_data) -> { 43 47 case image.get_image_information(image_data) { 44 48 Ok(info) -> ··· 47 51 digit, 48 52 CachedImage(data: image_data, info: info), 49 53 ) 50 - Error(_) -> accumulated_digits 54 + Error(_) -> { 55 + wisp.log_error( 56 + "Error getting image information for " <> path, 57 + ) 58 + 59 + accumulated_digits 60 + } 51 61 } 52 62 } 53 - Error(_) -> accumulated_digits 63 + Error(_) -> { 64 + wisp.log_error("Error reading image file " <> path) 65 + 66 + accumulated_digits 67 + } 54 68 } 55 69 }), 56 70 )