Forum Discussion
Error handling is primary source is absent
- 6 years ago
Hi Artur,
Your issue is with File.Contents: It gets an error trying to access the file but transforms this error into a binary anyway. So, when try is executed it gets a value but without errors, since the error is inside this value.
Since error are transferable, I'm not sure how this happens.
It is -- for me -- a bug of the pqengine evaluation system.
Aaaaanyway,
Try using file.contents alone, something like:Source = try (try File.Contents(filestring1))[Value]{0},Source_final = if Source[HasError] then File.Contents(filestring2) else File.Contents(filestring1)Nah, I actually tested this. It won't work since the error is still inside the binary. It happens on accessing it. This will work:Source = try Binary.Length((try File.Contents(filestring1))[Value])
Source_final = if Source[HasError] then File.Contents(filestring2) else File.Contents(filestring1)
And then apply the csv transformations
Edit2: You could also simplify step1 as :
try Binary.Length(File.Contents(filestring1))
Hi Artur,
Your issue is with File.Contents: It gets an error trying to access the file but transforms this error into a binary anyway. So, when try is executed it gets a value but without errors, since the error is inside this value.
Since error are transferable, I'm not sure how this happens.
It is -- for me -- a bug of the pqengine evaluation system.
Aaaaanyway,
Try using file.contents alone, something like:Source = try (try File.Contents(filestring1))[Value]{0},Source_final = if Source[HasError] then File.Contents(filestring2) else File.Contents(filestring1)Nah, I actually tested this. It won't work since the error is still inside the binary. It happens on accessing it. This will work:
Source = try Binary.Length((try File.Contents(filestring1))[Value])
Source_final = if Source[HasError] then File.Contents(filestring2) else File.Contents(filestring1)
And then apply the csv transformations
Edit2: You could also simplify step1 as :
try Binary.Length(File.Contents(filestring1))
It works, thank you very much! 🙂