mirror of
https://github.com/github/codeql.git
synced 2026-01-29 22:32:58 +01:00
co-authored-by: Sam Partington <sampart@github.com> co-authored-by: Robin Neatherway <rneatherway@github.com>
36 lines
766 B
XML
36 lines
766 B
XML
<!DOCTYPE qhelp PUBLIC
|
||
"-//Semmle//qhelp//EN"
|
||
"qhelp.dtd">
|
||
<qhelp>
|
||
|
||
<overview>
|
||
<p>GORM errors are returned as a field of the return value instead of a separate return value.</p>
|
||
|
||
<p>It is therefore very easy to miss that an error may occur and omit error handling routines.</p>
|
||
</overview>
|
||
<recommendation>
|
||
|
||
<p>Ensure that GORM errors are checked.</p>
|
||
|
||
</recommendation>
|
||
<example>
|
||
|
||
<p>In the example below, </p>
|
||
|
||
<sample src="MissingErrorCheck.go" />
|
||
|
||
<p>The corrected version of <code>user</code> checks <code>err</code> before using <code>ptr</code>.</p>
|
||
|
||
<sample src="MissingErrorCheckGood.go" />
|
||
|
||
</example>
|
||
<references>
|
||
|
||
<li>
|
||
The Go Blog:
|
||
<a href="https://blog.golang.org/error-handling-and-go">Error handling and Go</a>.
|
||
</li>
|
||
|
||
</references>
|
||
</qhelp>
|