I prefer to write solid shell code, so the errexit & nounset is alway set.
The following code will stop at bad_command line
#!/bin/b
The accepted answer is good, but I think it could be refactored to be even better; more generic, easier to refactor and read:
some_command_status=$(some_command && echo $? || echo $?)
vs.
some_command && some_command_status=$? || some_command_status=$?