Views: 12618
Last Modified: 23.03.2023
In the old core, API tried to interpret for a user/developer and was overlooking errors and inaccuracies. As a result, errors that are difficult to catch may occur. In addition, such an approach causes a lot of implicit agreements that must be taken into account.
For example, a user/developer selects entries for deletion using a filter. In this case, they incidentally make a writing error in the filter name. A typical API of the old core will ignore this filter and return all the entries. The next instruction will successfully delete all of these entries.
The method changes in the new core D7. API does not have to guess anything for a user. API must respond appropriately if it meets an unexpected situation, such as an unknown filter, no id transmitted, lack of value, excessive value, must not be invoked in this mode, etc.
When an error is displayed on the screen (if the debugging mode is available), connects the file /error.php (The file /error.php is located in site root. It can contain, for example, error message print).
Example of error.php
|
<table cellpadding="1" cellspacing="0" width="35%" bgcolor="#9C9A9C">
<tr>
<td><table cellpadding="5" cellspacing="0" width="100%">
<tr>
<td bgcolor="#FFFFFF" align="center"><FONT face="Verdana, Arial, Helvetica, sans-serif" size="-1">
<font color="#FF0000"><b><?echo "No such filter!"?></b></font><br>Check name and try again.</font></td>
</tr>
</table></td>
</tr>
</table>
|
You can print error in the site design inside this file, as well as specify HTTP status code (for example, "500 Internal Server Error").