📄 manual_error_trapping.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html lang="en"><head><title>Error Trapping - Universal Driver Documentation</title><meta http-equiv="Content-type" content="text/html; charset=iso-8859-1"><meta name="robots" content="index,follow"><link rel="shortcut icon" href="/favicon.ico"><link rel="stylesheet" href="/dscud/style/wikiprintable.css"><script type="text/javascript" src="/dscud/style/wikibits.js"></script><style type='text/css'><!--a.new, #quickbar a.new { color: #CC2200; }#quickbar { position: absolute; top: 4px; left: 4px; border-right: 1px solid gray; }#article { margin-left: 152px; margin-right: 4px; }//--></style></head><body bgcolor='#FFFFFF'><div class='titlebox'><h1 class='pagetitle'>Error Trapping</h1><span class='subtitle'>Universal Driver Documentation</span></div><div class='navbox'><a href="manual_Main_Page.html" class='printable' title ="Main Page">Main Page</a> || <a href="manual_Table_of_Contents.html" class='printable' title ="Table of Contents">Table_of_Contents</a> || <a href="http://www.diamondsystems.com/">Diamond Systems Website</a></div></div><div class='bodytext'>All driver functions provide a basic error trapping mechanism that stores the last reported error in the driver. If your application is not behaving properly, you can check for the last error by calling the function <tt><a href="manual_DscGetLastError.html" class='printable' title ="DscGetLastError">dscGetLastError</a>()</tt>. This function takes an <tt><a href="manual_ERRPARAMS.html" class='printable' title ="ERRPARAMS">ERRPARAMS</a></tt> structure pointer as its argument.
<p>
Nearly all of the available functions in the DSCUD API return a <tt>BYTE</tt> value upon completion. This value represents an error code that will inform you as to whether or not the function call was successful. You should always check if the result returns a <tt>DE_NONE</tt> value (signifying that no errors were reported), as the code below illustrates:
<p>
<pre>
BYTE result;
ERRPARAMS errparams;
if ((result = dscInit(DSC_VERSION)) != DE_NONE)
{
dscGetLastError(&errparams);
fprintf(stderr, "dscInit failed: %s (%s)\n", dscGetErrorString(result), errparams.errstring);
return result;
}
</pre>
<p>
In this code snippet, the <tt>BYTE</tt> result of executing a particular driver function (<tt><a href="manual_DscInit.html" class='printable' title ="DscInit">dscInit</a>()</tt> in this case) is stored and checked against the expected return value (<tt>DE_NONE</tt>). Anytime a function does not complete successfully, an error code other than <tt>DE_NONE</tt> will be generated, and the current API function will terminate. The function <tt><a href="manual_DscGetErrorString.html" class='printable' title ="DscGetErrorString">dscGetErrorString</a>()</tt> provides a description of the error that occurred.
<p></div><p><em> <br> This page was last modified 00:16, 4 Feb 2004.<br>Copyright (c) 2004 Diamond Systems. All Rights Reserved.</em><!-- Time since request: 0.15 secs. --></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -