diff options
author | Hayleigh Thompson <me@hayleigh.dev> | 2024-01-23 17:08:11 +0000 |
---|---|---|
committer | Hayleigh Thompson <me@hayleigh.dev> | 2024-01-23 17:08:11 +0000 |
commit | 817ad4fd02872a54f7102ca885b3675402763d75 (patch) | |
tree | 8af7d6748b2e632ad3a2e5f852109df7c1f2436a /src/lustre.gleam | |
parent | 16c59697e8d498ec00094163a11957b22b849e3a (diff) | |
download | lustre-817ad4fd02872a54f7102ca885b3675402763d75.tar.gz lustre-817ad4fd02872a54f7102ca885b3675402763d75.zip |
:recycle: Add more context to Error type.
Diffstat (limited to 'src/lustre.gleam')
-rw-r--r-- | src/lustre.gleam | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/lustre.gleam b/src/lustre.gleam index 74742e1..77c86cf 100644 --- a/src/lustre.gleam +++ b/src/lustre.gleam @@ -155,9 +155,9 @@ pub type Action(runtime, msg) = /// pub type Error { ActorError(StartError) - BadComponentName - ComponentAlreadyRegistered - ElementNotFound + BadComponentName(name: String) + ComponentAlreadyRegistered(name: String) + ElementNotFound(selector: String) NotABrowser NotErlang } @@ -232,11 +232,10 @@ pub fn start( } @external(javascript, "./client-runtime.ffi.mjs", "start") -fn do_start( - _app: App(flags, model, msg), - _selector: String, - _flags: flags, -) -> Result(fn(Action(ClientSpa, msg)) -> Nil, Error) { +fn do_start(_app: App(flags, model, msg), _selector: String, _flags: flags) -> Result( + fn(Action(ClientSpa, msg)) -> Nil, + Error, +) { // It should never be possible for the body of this function to execute on the // Erlang target because the `is_browser` guard will prevent it. Instead of // a panic, we still return a well-typed `Error` here in the case where someone @@ -247,10 +246,10 @@ fn do_start( /// /// @external(javascript, "./server-runtime.ffi.mjs", "start") -pub fn start_server_component( - app: App(flags, model, msg), - with flags: flags, -) -> Result(fn(Action(ServerComponent, msg)) -> Nil, Error) { +pub fn start_server_component(app: App(flags, model, msg), with flags: flags) -> Result( + fn(Action(ServerComponent, msg)) -> Nil, + Error, +) { use runtime <- result.map(start_actor(app, flags)) actor.send(runtime, _) } |