Commonize error handling across all operations
This commit is contained in:
1 parent
441fc9bc65
commit
556c821cc6
4 files changed
+7
-10
No files matched your search
+2
-2
@@ -35,8 +35,8 @@ module Rscons
|
||||
:SharedObject,
|
||||
]
|
||||
|
||||
# Class to represent a fatal error while building a target.
|
||||
class BuildError < RuntimeError; end
|
||||
# Class to represent a fatal error during an Rscons operation.
|
||||
class RsconsError < RuntimeError; end
|
||||
|
||||
class << self
|
||||
|
||||
|
||||
@@ -136,8 +136,8 @@ module Rscons
|
||||
env.process
|
||||
end
|
||||
0
|
||||
rescue BuildError => be
|
||||
Ansi.write($stderr, :red, be.message, :reset, "\n")
|
||||
rescue RsconsError => e
|
||||
Ansi.write($stderr, :red, e.message, :reset, "\n")
|
||||
1
|
||||
end
|
||||
end
|
||||
@@ -193,7 +193,7 @@ module Rscons
|
||||
co = ConfigureOp.new(options)
|
||||
begin
|
||||
@script.configure(co)
|
||||
rescue ConfigureOp::ConfigureFailure
|
||||
rescue RsconsError
|
||||
Ansi.write($stderr, :red, "Configuration failed", :reset, "\n")
|
||||
rv = 1
|
||||
end
|
||||
|
||||
@@ -5,9 +5,6 @@ module Rscons
|
||||
# Class to manage a configure operation.
|
||||
class ConfigureOp
|
||||
|
||||
# Exception raised when a configuration error occurs.
|
||||
class ConfigureFailure < Exception; end
|
||||
|
||||
# Create a ConfigureOp.
|
||||
#
|
||||
# @param options [Hash]
|
||||
@@ -407,7 +404,7 @@ module Rscons
|
||||
options[:on_fail].call
|
||||
end
|
||||
if should_fail
|
||||
raise ConfigureFailure.new
|
||||
raise RsconsError.new
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -288,7 +288,7 @@ module Rscons
|
||||
if Cache.instance["failed_commands"].size > 0
|
||||
msg += "\nUse -F to view the failed command log from the previous build operation"
|
||||
end
|
||||
raise BuildError.new(msg)
|
||||
raise RsconsError.new(msg)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in new issue
Block a user