Print error details to file

If I run a wrong line, in the listener I can see the error details.
But if the wrong line is under a Try function, the listener doesn't show me the error.
Using throw() solve this problem showing the error details in the listener... but if I want to print the error details to file?

I know that I can use getCurrentException() inside a catch, but it returns only the Exception, not all the details of the error.

Someone can help me, please?

Thanks,
David

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
miauu's picture

Ok, but what is the error

Ok, but what is the error when the try()catch() is removed?
Did you merge files, or... What is the reason for the problem - MAX can't load them, cant't merge them, or....?
Once we found what causes the problems then there is a big chance to remove the try()catch() from the final scrip.
I will go now, but if you post your code Branko can help you to resolve the problems. :)

David_Lee's picture

Thanks a lot miauu for your

Thanks a lot miauu for your reply (and patience).
But as I say as reply to your other answers, I have thousand of files to process.
Every files is made from different user, using different configuration and render engines/materials. There are lots of things that could be wrong.
For lots of files I processed, my script works perfectly but sometimes some files have something unexpected that stop the process.
Looping on over 12.000 files takes approximately 5 or 6 days and it's impossible for me to stay in front of my pc for all the time needed.
Using try and catch is a solution to avoid the loop stop, but with it I can't see what is gone wrong.

miauu's picture

Use this as

Use this as reference:

(
	local logFile = createFile @"D:\logFIle.txt"
	try
	(
		for i = 1 to 10 do format "i= % \n"  i to:logFile
 
	)
	catch()
	close logFile
)

I think the better solution is to temporary remove the try()catch(), so you can see where the script fails. Then you can fix the errors.

David_Lee's picture

Your solution logs all but

Your solution logs all but not the errors.
Remove try and catch temporary is useful if I run the script once in 3dsmax.

My script is doing a loop on a list of max files and what I need is to avoid stops when the script encounter a problem.
Try and Catch solve this problem, but it's impossible to know if there was errors and what errors the script found.

barigazy's picture

:) +1

Haha! You are faster

bga

miauu's picture

But my code will not prints

But my code will not prints the error, but how to get the error message? :)
What I always do is to remove try()catch() and find the problem.

David_Lee's picture

My script is doing a loop on

My script is doing a loop on a list of max files and what I need is to avoid stops when the script encounter a problem.
Try and Catch solve this problem, but it's impossible to know if there was errors and what errors the script found.

So I need a way to print to a file the error details everytime someting goes wrong during the loop.

barigazy's picture

...

post what you have for now to see what's your plan to do

bga

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.