Maple Professionel
Maple Académique
Maple Edition Étudiant
Maple Personal Edition
Maple Player
Maple Player for iPad
MapleSim Professionel
MapleSim Académique
Maple T.A. - Suite d'examens de classement
Maple T.A. MAA Placement Test Suite
Möbius - Didacticiels de mathématiques en ligne
Machine Design / Industrial Automation
Aéronautique
Ingénierie des véhicules
Robotics
Energie
System Simulation and Analysis
Model development for HIL
Modélisation du procédé pour la conception de systèmes de contrôle
Robotics/Motion Control/Mechatronics
Other Application Areas
Enseignement des mathématiques
Enseignement de l’ingénierie
Enseignement secondaire et supérieur (CPGE, BTS)
Tests et évaluations
Etudiants
Modélisation financière
Recherche opérationnelle
Calcul haute performance
Physique
Webinaires en direct
Webinaires enregistrés
Agenda des évènements
Forum MaplePrimes
Blog Maplesoft
Membres Maplesoft
Maple Ambassador Program
MapleCloud
Livres blancs techniques
Bulletin électronique
Livres Maple
Math Matters
Portail des applications
Galerie de modèles MapleSim
Cas d'Etudes Utilisateur
Exploring Engineering Fundamentals
Concepts d’enseignement avec Maple
Centre d’accueil utilisateur Maplesoft
Centre de ressources pour enseignants
Centre d’assistance aux étudiants
traperror (and variable lasterror) - trap an error condition
Calling Sequence
traperror(expr1, expr2, ...)
Parameters
expr1, expr2, ...
-
any expressions
Description
Important: The command traperror and the variable lasterror have been deprecated. Use the superseding construct try...catch...end try to trap errors instead. The variable lastexception supercedes lasterror.
The traperror command sets an error trap prior to evaluating its arguments. If an error occurs either during evaluation or during simplification, traperror returns the name, string, or expression sequence corresponding to the error message of the first error occurring. Each call to traperror clears the variable before executing.
Otherwise, it simply returns its simplified evaluated arguments.
The most recently occurring error is stored in the variable lasterror. This variable can be manipulated as any other variable. The lasterror variable is useful for checking the results of traperror as in the following.
Note: The traperror command and the lasterror variable must appear in this order.
The following errors cannot be trapped, because they are not something from which a Maple program can reasonably recover.
interrupted
assertion failed
stack overflow
object too large
out of memory
The time expired error, which is generated when the time limit set by the timelimit function expires, can be trapped only outside the call to timelimit.
The time expired error is not caught by traperror within a computation being carried out under a time limit. This allows you to time-limit a computation that uses traperror.
Thread Safety
The traperror (and variable lasterror) command is thread-safe as of Maple 15.
For more information on thread safety, see index/threadsafe.
Examples
Important: The command traperror and the variable lasterror have been deprecated. Use the superseding construct try...catch...end try to trap errors instead.
`Result: x =`, 0, `f(x) =`, 1
Error, numeric exception: division by zero
See Also
error, stoperror, try
Download Help Document