Errors 
In order to have full control over the tasks performed, it is necessary to know the errors from their traceback, screenshot or even in result files.
Here we will cover how to create and send errors to the platform.
Create simple error 
Using this method to create a simple error in Maestro.
In addition to having standard tags, it is possible to send customizable tags using the same method.
Python Java Javascript Typescript C# 
try : 
div  =  0  /  0 
except  Exception  as  error : 
maestro . error ( task_id = task . id ,  exception = error ,  tags = { "custom" :  "tag" }) 
 
try   { 
     int   div   =   0 / 0 ; 
}   catch   ( Exception   error )   { 
     Map < String ,   Object >   tags   =   new   HashMap <> (); 
     tags . put ( "custom" ,   "tag" ); 
     maestro . createError ( task . id ,   error ,   null ,   tags ,   null ); 
} 
 
try   { 
     eval ( "hoo bar" ); 
}   catch   ( error )   { 
     await   maestro . createError ( task . id ,   error ,   { "custom" :   "tag" }) 
} 
 
try   { 
     eval ( "hoo bar" ); 
}   catch   ( error :   any )   { 
     await   maestro . createError ( task . id ,   error ,   { "custom" :   "tag" }) 
} 
 
try   { 
     throw   new   Exception ( "test" ); 
}   catch   ( Exception   ex )   { 
     Dictionary < string ,   object >   additionalTags   =   new   Dictionary < string ,   object > 
     { 
         {   "custom" ,   "tag"   }, 
     }; 
     await   instance . CreateErrorAsync ( ex ,   task . Id ,   null ,   additionalTags ); 
} 
 
 
Sending screenshot 
It is possible to send the screenshot of the screen passing the file path.
Python Java Javascript Typescript C# 
try : 
div  =  0  /  0 
except  Exception  as  error : 
filepath  =  '/home/test/screenshot.png' 
maestro . error ( task_id = task . id ,  exception = error ,  screenshot = filepath ) 
 
try   { 
     int   div   =   0 / 0 ; 
}   catch   ( Exception   error )   {          
     File   screenshot   =   new   File ( "/home/test/screenshot.png" ); 
     maestro . createError ( task . id ,   error ,   screenshot ,   null ,   null ); 
} 
 
try   { 
     eval ( "hoo bar" ); 
}   catch   ( error )   { 
     const   filepath   =   '/home/test/screenshot.png' 
     await   maestro . createError ( task . id ,   error ,   {},   filepath ) 
} 
 
try   { 
     eval ( "hoo bar" ); 
}   catch   ( error :   any )   { 
     const   filepath :   string   =   '/home/test/screenshot.png' 
     await   maestro . createError ( task . id ,   error ,   {},   filepath ) 
} 
 
try   { 
     throw   new   Exception ( "test" ); 
}   catch   ( Exception   ex )   { 
     string   filepath   =   "/home/test/screenshot.png" ; 
     await   instance . CreateErrorAsync ( ex ,   task . Id ,   filepath ); 
} 
 
 
Tip
You can easily save screenshots for Desktop and Web automations
with the BotCity Frameworks.
 
Sending attachments 
It is possible to send files to the error in the Orchestrator, it must be done as follows:
Python Java Javascript Typescript C# 
try : 
div  =  0  /  0 
except  Exception  as  error : 
attachments  =  [ '/home/test/error.png' ,  '/home/test/test.txt' ] 
maestro . error ( task_id = task . id ,  exception = error ,  attachments = attachments ) 
 
try   { 
     int   div   =   0 / 0 ; 
}   catch   ( Exception   error )   { 
     List < File >   attachments   =   new   ArrayList <> (); 
     attachments . add ( new   File ( "/home/test/error.png" )); 
     attachments . add ( new   File ( "/home/test/test.txt" )); 
     maestro . createError ( task . id ,   error ,   null ,   null ,   attachments ); 
} 
 
try   { 
     eval ( "hoo bar" ); 
}   catch   ( error )   { 
     const   attachments   =   [ '/home/test/file.txt' ,   '/home/test/file2.txt' ] 
     await   maestro . createError ( task . id ,   error ,   {},   '' ,   attachments ) 
} 
 
try   { 
     eval ( "hoo bar" ); 
}   catch   ( error :   any )   { 
     const   attachments :   string []   =   [ '/home/test/file.txt' ,   '/home/test/file2.txt' ] 
     await   maestro . createError ( task . id ,   error ,   {},   '' ,   attachments ) 
} 
 
try   { 
     throw   new   Exception ( "test" ); 
}   catch   ( Exception   ex )   { 
     List < string >   attachments   =   [ "/home/test/error.png" ,   "/home/test/test.txt" ]; 
     await   instance . CreateErrorAsync ( ex ,   task . Id ,   "" ,   null ,   attachments ); 
}