11.07.2015 Views

webMathematica™ Wolfram - Wolfram Research

webMathematica™ Wolfram - Wolfram Research

webMathematica™ Wolfram - Wolfram Research

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

webMathematica User Guide 171Handling ErrorsThere are a number of ways that webMathematica computations can lead to an error. An inputmight fail the security test, the computation might take too long so that the Mathematica kernelis restarted, or there might be some type of page logic error. You can learn about certain typesof errors and, often, solve them using the logging system. However, it is not possible to avoidall errors, for example you cannot predict all inputs to the server, so some of them might failthe security test. In these cases you might want to customize the way the error is handled.When an error is generated webMathematica deals with it in one of two ways. For serious errorsthat require the Mathematica kernel to be restarted, the request results in an HTTP error ofstatus 403, indicating that the server could not complete the request. Alternatively, other errorsresult in a Mathematica exception being thrown and this leads to a normal page being returned,but with some special text being inserted for the error.If you want to customize the handling of these errors, you can do this with Mathematica code tocatch the Mathematica exceptions and by adding an error page to handle the HTTP error.Catching Mathematica Error ExceptionswebMathematica throws errors in Mathematica as MSPException expressions, and you can addcode to catch these. The exceptions that can be caught are listed below.MSPException@" ParseError "DMSPException@" SecurityError "DMSPException@" ValueError "DMSPException@" VariableError "DMSPException@" NoValueError "DMSPException@" VersionError "Dif the value cannot be interpreted by Mathematicaif the value does not pass the security testif the value is not a string, this indicates a programmaticerror by the page authorif the variable is not a Mathematica symbol, this indicates aprogrammatic error by the page authorif a variable has no valueif a version mismatch problem is foundSome sample code that uses Catch to catch a security exception is shown below.Catch[ expr, MSPException["SecurityError"], errorFunction]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!