Assign activity - Try Catch doesn't catch the exception - Job stopped with an unexpected exit code: 0xE0434352

Hi,

Among the attachment we receive for processing, there is a bad jpg file. (Task.jpg)
When I try to create the image, UiPath crashes with Job stopped with an unexpected exit code: 0xE0434352 instead of going to the Catch block

myimage=System.Drawing.Image.FromFile("Task.jpg")

Trying the same in VisualBasic, I go correctly on the Catch block with the exception Out of memory

    Dim myimage As System.Drawing.Image
    Try
        myimage = System.Drawing.Image.FromFile("C:\temp\mmsort\Task.jpg")
    Catch ex As Exception
        MsgBox("here is the exception")
    End Try

I’m attaching the UiPath used for testing.

emailtest.zip (61.6 KB)

Hi @c.ciprian ,

i too tried at my end not able to capture the exception in catch block. Not sure this is a bug or some other way to handle this exception. lets see what uipath team will say about this. thanks.

Hi,

0xE0434352 is the exception code for all .NET exceptions so that won’t tell you much.

I’ve had this issue before aswell and I was very confused the TryCatch Block didn’t catch the exception. Can someone elaborate? @ClaytonM @bcorrea @loginerror

Thanks

@lukasziebold I’m certain I have gotten this error too, maybe when taking screenshots. But I can’t remember specific examples.

@c.ciprian
I think you can get around this issue by reading the image into a file stream. There are also many possible solutions to check for valid image out there online if you’re curious.

I’m not an expert and just put together a few activities that ended up throwing an “invalid parameter” message that can be caught by the Try/Catch
image

There’s probably a more feasible method around this idea, but hopefully this helps anyway.

  1. Assign to a System.IO.Stream type => new FileStream(path, FileMode.Open, FileAccess.Read)
  2. Assign to Image from stream => System.Drawing.Image.FromStream(streamVariable)
  3. Ideally, Close and Dispose of stream in both Try side and Catch side
    Sequence.xaml (8.9 KB)
1 Like

I am sure there are other solutions and approaches, but I’m not interested in that.
I am interested in having UiPath functioning correctly and allowing me to choose whatever approach I consider adequate. Having a Try/Catch block that fails means that no matter what my choice would be, it can go sideways as the exception is not caught.

Understandable, but I think it’s on the .net side rather than UiPath, when trying to read corrupted files.

I would recommend taking one of the C# or vb.net approaches out there even if you recreate it through UiPath activities, which are designed to identify “if the image is valid or not”. Try/Catch is usually to be avoided, in my opinion. For example, if you have an invalid data type like converting characters to a number, you would check if it is a valid type before the conversion rather than use a Try/Catch. Try/Catch also makes Debug mode more annoying cause it always stops there. That’s my perspective, anyway.

Thanks

How would you check if it’s a valid image, in this case?

Thanks for your input!

I remember this behaviour occuring when robots try taking screenshots in Windows Session 0.

Checking if the image is a valid type seems reasonable, I’m not sure about Try/Catch though. It seems to be an essential part of the UiPath ReFramework making it hard to avoid it in most projects I work on.

Just for the record - does it also crash from Studio or only when you execute it from Assistant/unattended as a published automation?

Hi Maciej (@loginerror),

The error is present both in Studio and unattend as a published automation.

1 Like

Thanks for confirming. I recorded this issue in our issue tracker. It looks like a clear bug to me.

1 Like

Hi @c.ciprian,

The issue you are seeing is because you encounter a fatal exception. These exceptions are not caught by the Try/Catch block, as they are caught at an upper level. The following exceptions are fatal:

exception is FatalException ||
(exception is OutOfMemoryException && !(exception is InsufficientMemoryException)) ||
exception is ThreadAbortException ||
exception is FatalInternalException

Best regards,
Andrei

2 Likes

Hi @erghe ,

Is there any way to have the process continue after encountering one of this exceptions? In VB.NET this is caught correctly…
Otherwise it means that a corrupted file can kill my flow and I can do nothing about it.

Thanks,
Ciprian

Hi @c.ciprian,

Unfortunately we don’t have a way to fix this for Legacy projects. We are trying to see if we can fix this for Windows - .net6 or cross-platform projects.

Best regards,
Andrei

1 Like

Hi Andrei,

any news on this?

Best,
Lukas