From 5033282b91b16fd77badbaf0ddeca6bbd674451f Mon Sep 17 00:00:00 2001 From: Filip Hoffmann Date: Thu, 5 Mar 2026 23:42:25 +0100 Subject: [PATCH] example: fix: no more string.inspect logging i apologize for bad error types, i promise i'll be better in the future --- examples/your_first_bot/manifest.toml | 11 +++++----- .../your_first_bot/src/your_first_bot.gleam | 22 +++++++------------ 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/examples/your_first_bot/manifest.toml b/examples/your_first_bot/manifest.toml index d43251f..53df1a8 100644 --- a/examples/your_first_bot/manifest.toml +++ b/examples/your_first_bot/manifest.toml @@ -12,17 +12,18 @@ packages = [ { name = "gleam_httpc", version = "5.0.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_http", "gleam_stdlib"], otp_app = "gleam_httpc", source = "hex", outer_checksum = "C545172618D07811494E97AAA4A0FB34DA6F6D0061FDC8041C2F8E3BE2B2E48F" }, { name = "gleam_json", version = "3.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_json", source = "hex", outer_checksum = "44FDAA8847BE8FC48CA7A1C089706BD54BADCC4C45B237A992EDDF9F2CDB2836" }, { name = "gleam_otp", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "gleam_otp", source = "hex", outer_checksum = "BA6A294E295E428EC1562DC1C11EA7530DCB981E8359134BEABC8493B7B2258E" }, - { name = "gleam_stdlib", version = "0.67.1", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "6CE3E4189A8B8EC2F73AB61A2FBDE49F159D6C9C61C49E3B3082E439F260D3D0" }, - { name = "gleam_time", version = "1.6.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_time", source = "hex", outer_checksum = "0DF3834D20193F0A38D0EB21F0A78D48F2EC276C285969131B86DF8D4EF9E762" }, + { name = "gleam_stdlib", version = "0.69.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "AAB0962BEBFAA67A2FBEE9EEE218B057756808DC9AF77430F5182C6115B3A315" }, + { name = "gleam_time", version = "1.7.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_time", source = "hex", outer_checksum = "56DB0EF9433826D3B99DB0B4AF7A2BFED13D09755EC64B1DAAB46F804A9AD47D" }, { name = "gleeunit", version = "1.9.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "DA9553CE58B67924B3C631F96FE3370C49EB6D6DC6B384EC4862CC4AAA718F3C" }, { name = "gramps", version = "6.0.0", build_tools = ["gleam"], requirements = ["gleam_crypto", "gleam_erlang", "gleam_http", "gleam_stdlib"], otp_app = "gramps", source = "hex", outer_checksum = "8B7195978FBFD30B43DF791A8A272041B81E45D245314D7A41FC57237AA882A0" }, - { name = "grom", version = "0.0.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_http", "gleam_httpc", "gleam_json", "gleam_otp", "gleam_stdlib", "gleam_time", "grom_stratus", "multipart_form", "operating_system", "status_code"], source = "local", path = "../.." }, - { name = "grom_stratus", version = "1.0.2", build_tools = ["gleam"], requirements = ["exception", "gleam_crypto", "gleam_erlang", "gleam_http", "gleam_otp", "gleam_stdlib", "gramps", "logging"], otp_app = "grom_stratus", source = "hex", outer_checksum = "C4AFBF252838072B5DEED80813F71673901AE2155914DCA1FCDD8645FBD9D5B2" }, + { name = "grom", version = "5.1.3", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_http", "gleam_httpc", "gleam_json", "gleam_otp", "gleam_stdlib", "gleam_time", "multipart_form", "operating_system", "splitter", "status_code", "stratus"], source = "local", path = "../.." }, { name = "logging", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "logging", source = "hex", outer_checksum = "1098FBF10B54B44C2C7FDF0B01C1253CAFACDACABEFB4B0D027803246753E06D" }, { name = "multipart_form", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_http", "gleam_stdlib"], otp_app = "multipart_form", source = "hex", outer_checksum = "082C77A0C3BB1128FCD55491665E9B72BC943E849B67D02B08CFA6808AD8E47C" }, { name = "operating_system", version = "1.0.1", build_tools = ["gleam"], requirements = [], otp_app = "operating_system", source = "hex", outer_checksum = "682D4D19496E607A6E6229AA51A38A1400ED5067C2C54D56843DBCB0C61FFA6D" }, - { name = "simplifile", version = "2.3.1", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "957E0E5B75927659F1D2A1B7B75D7B9BA96FAA8D0C53EA71C4AD9CD0C6B848F6" }, + { name = "simplifile", version = "2.3.2", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "E049B4DACD4D206D87843BCF4C775A50AE0F50A52031A2FFB40C9ED07D6EC70A" }, + { name = "splitter", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "splitter", source = "hex", outer_checksum = "3DFD6B6C49E61EDAF6F7B27A42054A17CFF6CA2135FF553D0CB61C234D281DD0" }, { name = "status_code", version = "1.1.0", build_tools = ["gleam"], requirements = [], otp_app = "status_code", source = "hex", outer_checksum = "F6EC765345A634602AD030EB1B4D34A425873CBC223CEC595EBF062073CD70BC" }, + { name = "stratus", version = "2.0.0", build_tools = ["gleam"], requirements = ["exception", "gleam_crypto", "gleam_erlang", "gleam_http", "gleam_otp", "gleam_stdlib", "gramps", "logging"], otp_app = "stratus", source = "hex", outer_checksum = "DB81236C1E00C29C01FBED9D3B0946E7A74AEE7D515036C7BF152D22430ADE9E" }, ] [requirements] diff --git a/examples/your_first_bot/src/your_first_bot.gleam b/examples/your_first_bot/src/your_first_bot.gleam index 562fff8..51e0631 100644 --- a/examples/your_first_bot/src/your_first_bot.gleam +++ b/examples/your_first_bot/src/your_first_bot.gleam @@ -2,7 +2,6 @@ import dotenv_gleam import envoy import gleam/erlang/process import gleam/option.{Some} -import gleam/string import grom import grom/command import grom/gateway @@ -38,19 +37,17 @@ pub fn main() -> Nil { logging.log(logging.Info, "Started the gateway!") process.sleep_forever() } - Error(err) -> { - logging.log( - logging.Error, - "Couldn't start the gateway: " <> string.inspect(err), - ) - } + Error(_err) -> logging.log(logging.Error, "Couldn't start the gateway.") } } fn on_event(state: State, event: gateway.Event) { case event { - gateway.ErrorEvent(error) -> { - logging.log(logging.Warning, string.inspect(error)) + gateway.ErrorEvent(_error) -> { + // Better error event logging coming in the rewrite + // See the one-module branch for progesss! + // Sorry I can't do it now :( + logging.log(logging.Warning, "An event was errorneous") gateway.continue(state) } gateway.AllShardsReadyEvent(ready) -> on_ready(state, ready) @@ -84,11 +81,8 @@ fn on_ready(state: State, ready: gateway.AllShardsReadyMessage) { "Overwrote the commands for " <> ready.application.id, ) } - Error(err) -> { - logging.log( - logging.Error, - "Couldn't bulk overwrite global commands: " <> string.inspect(err), - ) + Error(_err) -> { + logging.log(logging.Error, "Couldn't bulk overwrite global commands.") } } -- 2.51.2