I have an eternal discussion in my work about why "error first" is "worng".
In order to ensure what I try to tell with error first is the following code pattern:
if condition:
raise Error()
code
Instead of if-else approach
if condition:
code
else:
raise Error()
I think that the first one (error first) is better because you only check your error conditions, you avoid using else statement, by logical error will be raised and never you execute the code.
But on the other hand, probably race conditions or any strange reason, if you encapsulate the error inside an else you are always are setting the logic, and probably is defensive programming approach in order to avoid errors.
The question is there is any reason beyond its de facto standard (in javascript), or there are any other design reasons.
Edit
Another argument is that if only have one error is not enough to do "error first", but anyway I think that if you select an error template for checking the flow of your code you should following in each place including one error code.
Thanks