Skip to content

Commit

Permalink
✨ Replaced Rake exception with our own
Browse files Browse the repository at this point in the history
Tasks not found produced Rake-specific exception that is confusing with all the other work to remove Rake from the direct experience of end users as well as beginning the process to move away from Rake. New exception message suppresses Rake messaging.
  • Loading branch information
mkarlesky committed Oct 29, 2024
1 parent bf23993 commit 33c05c5
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions bin/cli_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
# =========================================================================

require 'app_cfg'
require 'ceedling/constants' # From Ceedling application

# From Ceedling application
require 'ceedling/constants'
require 'ceedling/exceptions'

class CliHelper

Expand Down Expand Up @@ -246,7 +249,26 @@ def print_rake_tasks()

def run_rake_tasks(tasks)
Rake.application.collect_command_line_tasks( tasks )
Rake.application.top_level()

# Replace Rake's exception message to reduce any confusion
begin
Rake.application.top_level()

rescue RuntimeError => ex
# Check if exception contains an unknown Rake task message
matches = ex.message.match( /how to build task '(.+)'/i )

# If it does, replacing the message with our own
if matches.size == 2
message = "Unrecognized build task '#{matches[1]}'. List available build tasks with `ceedling help`."
raise CeedlingException.new( message )

# Otherwise, just re-raise
else
raise
end
end

end


Expand Down

0 comments on commit 33c05c5

Please sign in to comment.