This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the user-input-and-output category.
Last Updated: 2024-11-21
If you have an exception that stops a program, the message it gives should probably contain the word error.
This output was unclear.
$ RAILS_ENV=seed rails db:seed:replant
rails aborted!
Start elasticsearch
Does the output mean it was logging it having just started elasticsearch or did it want me to start it up?
A better version:
raise "Error: Please start elasticsearch"
or
def fail_with_message(msg)
raise "Error: #{}"
end
fail_with_message("Please start elasticsearch")
Preface your error messages with the word "Error" to make it clearer to the user what output is logs vs. error messages. Ideally send the error to STDERR too.