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

Configuration problems should print errors, not stack traces. #2067

Merged
merged 2 commits into from
Sep 12, 2024

Conversation

jordansissel
Copy link
Owner

@jordansissel jordansissel commented Sep 12, 2024

Raising unexpected exceptions will often produce a crash-like behavior which prints the exception and a stack trace. Stack traces are not helpful content in situations where a user has made a configuration error.

In most cases, known configuration issues should raise either FPM::Package::InvalidArgument or FPM::InvalidPackageConfiguration. (Honestly, I have forgotten why these two exceptions aren't just a single exception type).


Before:

% bin/fpm -s empty -t deb --deb-systemd /tmp/foo.test -n example
/Users/jls/projects/fpm/lib/fpm/package/deb.rb:528:in `block in output': Invalid systemd unit file extension: .test. Expected .service or .timer, or no extension. (ArgumentError)
	from /Users/jls/projects/fpm/lib/fpm/package/deb.rb:519:in `each'
	from /Users/jls/projects/fpm/lib/fpm/package/deb.rb:519:in `output'
	from /Users/jls/projects/fpm/lib/fpm/command.rb:508:in `execute'
	from /Users/jls/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/clamp-1.0.1/lib/clamp/command.rb:68:in `run'
<remainder of stack trace is omitted>

After:

% bin/fpm -s empty -t deb --deb-systemd /tmp/foo.test -n example
Invalid package configuration: Invalid systemd unit file extension: .test. Expected .service or .timer, or no extension. {:level=>:error}

Raising FPM::InvalidPackageConfiguration will allow the fpm command-line
to print an error message and exit non-zero.

Raising other exceptions will often produce a crash-like behavior which
prints the exception and a stack trace. Stack traces are not helpful
content in situations where a user has made a configuration error.
@jordansissel jordansissel changed the title Configuration errors should raise a specific exception Configuration problems should print errors, not stack traces. Sep 12, 2024
@jordansissel jordansissel merged commit fd06d93 into main Sep 12, 2024
3 checks passed
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

Successfully merging this pull request may close these issues.

1 participant