Start an application and handle failure paths · 3 Lessons
English

Flying V Application Development

Module 2 – Start an application and handle failure paths

Page 1 of 3 · About 15 minutes per lesson, including practice.

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.

Example code on Agila Forge ↗

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.