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