ScriptSpot

Forum topic · General Scripting

Print error details to file

By David_Lee · 2013-06-18

Description

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 (8)

miauu · 2013-06-18

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 · 2013-06-18

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 · 2013-06-18

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.

:) +1

barigazy · 2013-06-18

Haha! You are faster

miauu · 2013-06-18

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 · 2013-06-18

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.

David_Lee · 2013-06-18

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 · 2013-06-18

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