ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzahh_5.4.0.1/except.htm

97 lines
4.9 KiB
HTML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="reference" />
<meta name="DC.Title" content="Exceptions" />
<meta name="abstract" content="The IBM Toolbox for Java access classes throw exceptions when device errors, physical limitations, programming errors, or user input errors occur. The exception classes are based upon the type of error that occurs instead of the location where the error originates." />
<meta name="description" content="The IBM Toolbox for Java access classes throw exceptions when device errors, physical limitations, programming errors, or user input errors occur. The exception classes are based upon the type of error that occurs instead of the location where the error originates." />
<meta name="DC.Relation" scheme="URI" content="progtips.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="except" />
<meta name="DC.Language" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>Exceptions</title>
</head>
<body id="except"><a name="except"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Exceptions</h1>
<div><p>The IBM<sup>®</sup> Toolbox
for Java™ access
classes throw exceptions when device errors, physical limitations, programming
errors, or user input errors occur. The exception classes are based upon the
type of error that occurs instead of the location where the error originates.</p>
<div class="section"><p>Most exceptions contain the following information:</p>
<ul><li><strong>Error type:</strong> The exception object that is thrown indicates the type
of error that occurred. Errors of the same type are grouped together in an
exception class.</li>
<li><strong>Error details:</strong> The exception contains a return code to further
identify the cause of the error that occurred. The return code values are
constants within the exception class.</li>
<li><strong>Error text:</strong> The exception contains a text string that describes
the error that occurred. The string is translated in the locale of the client Java virtual
machine.</li>
</ul>
</div>
<div class="section" id="except__excex1"><a name="except__excex1"><!-- --></a><h4 class="sectiontitle">Example: Catching a thrown exception</h4><div class="p">The
following example shows how to catch a thrown exception, retrieve the return
code, and display the exception text: <div class="note"><span class="notetitle">Note:</span> Read the <a href="codedisclaimer.htm#codedisclaimer">Code
example disclaimer</a> for important legal information.</div>
</div>
<pre> // All the setup work to delete a file on the server through the
// IFSFile class is done. Now try deleting the file.
try
{
aFile.delete();
}
// The delete failed.
catch (ExtendedIOException e)
{
// Display the translated string containing the reason that the
// delete failed.
System.out.println(e);
// Get the return code out of the exception and display additional
// information based on the return code.
int rc = e.getReturnCode()
switch (rc)
{
case ExtendedIOException.FILE_IN_USE:
System.out.println("Delete failed, file is in use "):
break;
case ExtendedIOException.PATH_NOT_FOUND:
System.out.println("Delete failed, path not found ");
break;
// For every specific error that you want to track...
default:
System.out.println("Delete failed, rc = ");
System.out.println(rc);
}
}</pre>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="progtips.htm" title="This section features a variety of tips that can help you use IBM Toolbox for Java.">Tips for programming</a></div>
</div>
</div>
</body>
</html>