Module 2 – Start an application and handle failure paths
An application moves through states
The SDK models an application with an id, name, and internal started state. new_app rejects an empty id or name. The example follows the released hello application: create it, start it, request a capability, log useful work, and stop it. mut allows calls that change the application state.
import agila
fn main() {
mut app := agila.new_app('dev.student.study', 'Study Buddy') or {
eprintln(err.msg())
return
}
app.start() or {
eprintln(err.msg())
return
}
app.request(.ui) or { eprintln(err.msg()) }
agila.log('Ready to study')
app.stop()
}For a normal run, expect a start message, a requested-capability message, the app log, and a stop message. Read or as the place where this code handles a returned error. err.msg() obtains its message; return leaves the current function.
Reference: Agila SDK: application contract and hello_agila example.
Complete this lesson
Answer every check correctly to earn your lesson certificate. Feedback helps you review and try again.
Sign in · Save your progress and earn a certificate for this lesson.