Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing return value in SQL Backend? #183

Open
lord-alfred opened this issue Aug 23, 2019 · 1 comment
Open

Missing return value in SQL Backend? #183

lord-alfred opened this issue Aug 23, 2019 · 1 comment

Comments

@lord-alfred
Copy link
Contributor

lord-alfred commented Aug 23, 2019

As I already wrote - I am new to golang (thank you for guerrilla - I’m learning from it!).

Perhaps there is not enough return value here:

if execErr != nil {
Log().WithError(execErr).Error("There was a problem the insert")
}
return

Maybe:

	if execErr != nil {
		Log().WithError(execErr).Error("There was a problem the insert")
		return execErr
	}

Because calling this method will always return nil:

err := s.doQuery(1, db, stmt, &vals)
if err != nil {
return NewResult(fmt.Sprint("554 Error: could not save email")), StorageError
}

But I see from the logs that everything works as it should! But in Python there is such a rule: Explicit is better than implicit.

Maybe it should be explicitly prescribed here?

PS: It is very inconvenient that errors in this place are written to various log files.
Error "There was a problem the insert" is always written at main.log, and "554 Error: could not save email" is always written at server.log.

@andreypanin
Copy link

Hello @lord-alfred,

The return on line 120 is called naked and is possible because the function got a named return value execErr on line 100. Since error is an interface type, it defaults to nil at the start of the function. And this value is exactly what will be returned on line 120.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants