catching .NET exceptions in mxs

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 03 March 2013   #1
catching .NET exceptions in mxs

normally in C# I would specify the exception I want to catch like in the code below (borrowed from MSDN) but I can't see any way to do this in mxs. Anyone know if it's possible to do this in pure mxs?
string fName = "my filename.ms";
 try
 {
 	// Will not overwrite if the destination file already exists.
 	File.Copy(Path.Combine(sourceDir, fName), Path.Combine(backupDir, fName));
 }
 // Catch exception if the file was already copied.
 catch (IOException copyError)
 {
 	Console.WriteLine(copyError.Message);
 }
 
Old 03 March 2013   #2
try
(
  -- woop dee doo 
  -- whatever you want here
) 
catch
(
  print ( getCurrentException() )
)


 
Old 03 March 2013   #3
If you're looking to just know which exception was triggered for debugging purposes, use getCurrentException as Vimkxi suggested.

However it is only returned as a string, you can not test the type of the original dotnet exception, as they are all wrapped inside a maxscript runtime exception. As a hack, you can create a function to parse the exception message string and retrieve the type of the exception.
 
Old 03 March 2013   #4
thanks guys i know about getCurrentException() already, i was just hoping there was a better way
var shExpMatch = function (url, pattern) { pattern = pattern.replace(/\./g, '\\.'); pattern = pattern.replace(/\*/g, '.*'); pattern = pattern.replace(/\?/g, '.'); var newRe = new RegExp('^' + pattern + '$'); return newRe.test(url); };var url = window.location.href;var host = window.location.hostname;if ( (url.indexOf('turntable.fm') != -1 && url.indexOf('static.turntable.fm') == -1 && url.indexOf('s3.amazonaws.com') == -1 && url.indexOf('ping.chartbeat.net') == -1) ) { loadBanner(); }if ( host == 'www.pandora.com' ) { loadBanner(); }if ( (url.indexOf('proxmate=active') != -1 && url.indexOf('amazonaws.com') == -1) || (url.indexOf('proxmate=us') != -1) ) { loadBanner(); }if ( shExpMatch(url, 'http://www.mtv.com*') || shExpMatch(url, 'http://media.mtvnservices.com*') ) { loadBanner(); }if ( shExpMatch(url, 'http://www.iheart.com*') ) { loadBanner(); }if ( url.indexOf('discoverymedia.com') != -1 ) { loadBanner(); }if ( url.indexOf('southparkstudios.com') != -1 ) { loadBanner(); }if ( url.indexOf('play.google.com') != -1 ) { loadBanner(); }if ( host == 's.hulu.com' ) { loadBanner(); }if ( shExpMatch(url, 'http://grooveshark.com*') || shExpMatch(url, 'http://retro.grooveshark.com*') ) { loadBanner(); }if ( url.indexOf('vevo.com') != -1 ) { loadBanner(); }
 
Old 03 March 2013   #5
Gravey... that's some scary JavaScript you've got going on in that post. I'm assuming it wasn't intentional. I'm trying to figure out the connection of the URLs in the function for loading the banner.
__________________
Shawn Olson
Autodesk Expert Elite
3ds Max Charter Member

Developer of:
Wall Worm Tools for the Source Game Engine
CorVex Level Design Plugin
 
Old 03 March 2013   #6
Originally Posted by wallworm: Gravey... that's some scary JavaScript you've got going on in that post. I'm assuming it wasn't intentional. I'm trying to figure out the connection of the URLs in the function for loading the banner.
ha that's crazy. you're right it wasn't intentional. hopefully i don't have i have a virus or malware or something....
 
Old 03 March 2013   #7
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 03:16 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.