Skip to content

Modern Chan Err

Paul Squires edited this page Oct 19, 2026 · 5 revisions

Home › Goroutines and Channels › Goroutines and Channels › Err

Err

Returns why the context ended: "cancelled", "deadline exceeded", or "" while live.

Syntax

Err( )

Examples

#import "std/tasks"
using tasks

dim root as Context

'' Empty while the context is still live -- the same rule Go follows,
'' so a non-empty Err( ) means "finished, and this is why"
print "[" & root.Err( ) & "]"          '' []

dim c1 as CancelContext = WithCancel( root )
c1.Cancel( )
print c1.Err( )                        '' cancelled

dim c2 as CancelContext = WithTimeout( root, 20 )
sleep 100, 1
print c2.Err( )                        '' deadline exceeded

'' The two are distinguishable on purpose: a deadline is a failure to
'' finish in time, a cancel is someone deciding to stop

Library: Goroutines and Channels
Category: Goroutines and Channels
Documented under: Context

Clone this wiki locally