Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Kernel Error Handling

Keith Poole edited this page Jul 15, 2016 · 6 revisions

Error handling is performed by the functions error, waserror, nexterror and poperror

The proc structure, accessed by externup() contains an array of Label structures (errlab), which is used to catch errors called through the error() function.

Use This example shows how these functions are used:

// Get the Proc structure (must be called 'up')
Proc *up = externup();		

// save this location as an error handler
if (waserror()) {	
  // waserror returns 0 when it's called, and 1 if
  // it 'returns' again via the Label	
  ... error handling ...	
 // optionally call the next handler in errlab (not needed if the error is handled here)
  nexterror();			
}
... code that might call error() ...

// Remove the local handler
poperror();