Skip to content

Commit

Permalink
Cleanup some runtime setup error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
maxfierke committed Jan 28, 2024
1 parent 0bbb882 commit 25d0c23
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
2 changes: 2 additions & 0 deletions src/mstrap/cli.cr
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ DESC
Signal::TERM.trap { exit 1 }

Commander.run(cli, options.argv)
rescue e : MStrapError
logc e.message
rescue e
{% if flag?(:debug) %}
raise e
Expand Down
8 changes: 4 additions & 4 deletions src/mstrap/runtime.cr
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ module MStrap
# Returns whether the project uses the runtime
abstract def matches? : Bool

# Installs asdf plugin for the language runtime and installs any of the
# language runtime dependencies for the project.
# Installs runtime manager plugin for the language runtime and installs any
# of the language runtime dependencies for the project.
def setup
unless runtime_manager.has_plugin?(language_name)
log "--> Installing #{language_name} plugin to #{runtime_manager.name}: "
unless runtime_manager.install_plugin(language_name)
logc "There was an error adding the #{language_name} plugin to #{runtime_manager.name}. Check #{MStrap::Paths::LOG_FILE} or run again with --debug"
raise_setup_error!("There was an unexpected error adding the #{language_name} plugin to #{runtime_manager.name}")
end
success "OK"
end
Expand All @@ -82,7 +82,7 @@ module MStrap
if current_version && current_version != "" && !has_version?(current_version)
log "--> Installing #{language_name} #{current_version} via #{runtime_manager.name}: "
unless runtime_manager.install_version(language_name, current_version)
logc "There was an error installing #{language_name} #{current_version} via #{runtime_manager.name}. Check #{MStrap::Paths::LOG_FILE} or run again with --debug"
raise_setup_error!("There was an unexpected error installing #{current_version} via #{runtime_manager.name}")
end
success "OK"
end
Expand Down
6 changes: 0 additions & 6 deletions src/mstrap/runtimes/crystal.cr
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ module MStrap
# with Crystal via the chosen runtime manager and bootstrapping a Crystal
# project based on conventions.
class Crystal < Runtime
class SetupError < RuntimeSetupError
def initialize(message)
super("crystal", message)
end
end

def language_name : String
"crystal"
end
Expand Down

0 comments on commit 25d0c23

Please sign in to comment.