Skip to content
Playground(another site)

bynk.parse.expected_handler

Error Expected a handler.

A service or agent body is its handlers, each starting with on, beside its own clauses (a service's policies, an agent's key and store fields). The parser found something else where a handler should begin. The commonest cause is a helper fn, or a let, written inside the body: declare a helper beside the service, in the context, and its handlers can call it. Another is a handler with its on left off (GET("/a") …, call get() …). The position is the first token of the item that is not a handler.

Example

service api from http {
fn double(n: Int) -> Int { n * 2 } // ✗ only handlers go in a service
on GET("/a") () -> Effect[HttpResult[Int]] by Visitor { … }
}
fn double(n: Int) -> Int { n * 2 } // ✓ beside the service
service api from http {
on GET("/a") () -> Effect[HttpResult[Int]] by Visitor { … }
}

In the Book

See also

  • The grammar rule it governs: handler.
  • Every code in its category, Parser, on the diagnostic index.
  • bynk explain bynk.parse.expected_handler shows the same from the installed toolchain, without a network.