MATLAB BUILDER JA 2 Guide de l'utilisateur Page 65

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 292
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 64
Handling Errors
Handling Errors
Errors that occur during execution of an M-function or during data conversion
are s ignaled by a standard Java exception. This includes MATLAB run-time
errors as well as errors in your M-code.
In ge neral, there are two types of exceptions in Java: checked exceptions
and unchecked exceptions.
Handling Checked Exceptions
Checked exceptions must be de clared as thrown b y a m ethod using the Java
language
throws claus e. Java Builder components support one checked
exception:
com.mathworks.toolbox.javabuilder.MWException.This
exception class inherits from
java.lang.Exception and is thrown by every
MATLAB Compiler generated Java m ethod to signal that an error has
occurred during the call. All normal MATLAB run-time errors, as well as
user-created errors (e.g., a calling e rror in your M-code) are manifested as
MWExceptions.
The Java interface to each M-function declares itself as throwing an
MWException using the throws clause. For example, the myprimes M-function
shown previously has the following interface:
/* mlx interface List version */
public void myprimes(List lhs, List rhs) throws MWException
{
(implementation omitted)
}
/* mlx interface Array version */
public void myprimes(Object[] lhs, Object[] rhs) throws MWException
{
(implementation omitted)
}
/* Standard interface no inputs*/
public Object[] myprimes(int nargout) throws MWException
{
(implementation omitted)
}
/* Standard interface one input*/
3-19
Vue de la page 64
1 2 ... 60 61 62 63 64 65 66 67 68 69 70 ... 291 292

Commentaires sur ces manuels

Pas de commentaire