E07800: Web Service must have return value and it must be compatible with HTTPResponse
What went wrong
A service method is missing a return statement.
Worked examples
Compilable examples demonstrating this error and the correct fix:
- ek9 -q 869 (Why must all EK9 service methods declare a return value?)
How to fix it
- Add return statement with HTTPResponse
Common causes
- Forgot to return HTTPResponse
- Incomplete implementation
See also
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E07800: Web Service must have return value and it must be compatible with HTTPResponse
#!ek9 defines module error.e07800.bad defines class TextResponse with trait of HTTPResponse text as String? default private TextResponse() TextResponse() -> body as String this.text: body override contentType() as pure <- rtn as String: "text/plain" override content() <- rtn as Bytes: Bytes().withUtf8(text) override status() as pure <- rtn as Integer: 200 default operator ? defines service Addresses for :/addresses open //A service method answers every request byId() as GET for :/{id} -> id as String stdout <- Stdout() stdout.println(id)
Fixed: Declare the HTTPResponse it returns
#!ek9 defines module error.e07800.good defines class TextResponse with trait of HTTPResponse text as String? default private TextResponse() TextResponse() -> body as String this.text: body override contentType() as pure <- rtn as String: "text/plain" override content() <- rtn as Bytes: Bytes().withUtf8(text) override status() as pure <- rtn as Integer: 200 default operator ? defines service Addresses for :/addresses open byId() as GET for :/{id} -> id as String <- response as HTTPResponse: TextResponse(`address ${id}`)
Questions and answers
These Q&A entries show E07800 and its fix:
Found a problem?
If EK9 reported E07800 for a program you think is valid, or did not report it where it should have, use the compiler form with the smallest program that shows it. If this page is wrong or unclear, use the documentation form. Both are at github.com/ek9lang/ek9-issues.