Raise errors

You can raise custom errors using the raise syntax, and you can catch and handle errors using a try/except block .

Errors can be either a string or a map. You can use user-defined keys:

YAML

  
 - 
  
  STEP_NAME 
 
 : 
  
 raise 
 : 
  
  KEY_1 
 
 : 
  
  VALUE_1 
 
  
  KEY_2 
 
 : 
  
  VALUE_2 
 

JSON

  
 [ 
  
 { 
  
 " STEP_NAME 
" 
 : 
  
 { 
  
 "raise" 
 : 
  
 { 
  
 " KEY_1 
" 
 : 
  
 " VALUE_1 
" 
 , 
  
 " KEY_2 
" 
 : 
  
 " VALUE_2 
" 
  
 } 
  
 } 
  
 } 
  
 ] 

Examples

String

YAML

  
 - 
  
 step_a 
 : 
  
 raise 
 : 
  
 "Something 
  
 went 
  
 wrong." 

JSON

  
 [ 
  
 { 
  
 "step_a" 
 : 
  
 { 
  
 "raise" 
 : 
  
 "Something went wrong." 
  
 } 
  
 } 
  
 ] 

Map

YAML

  
 - 
  
 step_a 
 : 
  
 raise 
 : 
  
 code 
 : 
  
 55 
  
 message 
 : 
  
 "Something 
  
 went 
  
 wrong." 

JSON

  
 [ 
  
 { 
  
 "step_a" 
 : 
  
 { 
  
 "raise" 
 : 
  
 { 
  
 "code" 
 : 
  
 55 
 , 
  
 "message" 
 : 
  
 "Something went wrong." 
  
 } 
  
 } 
  
 } 
  
 ] 

What's next

Design a Mobile Site
View Site in Mobile | Classic
Share by: