SusSourceSusFileLoadError

class FileLoadError

Represents an error that occurred while loading a test file.

Definitions

def self.build(parent, path, error)

Build a new FileLoadError.

Signature

parameter parent Object

The parent context.

parameter path String

The path to the file that failed to load.

parameter error Exception

The error that occurred.

returns FileLoadError

A new FileLoadError instance.

Implementation

def self.build(parent, path, error)
	identity = Identity.file(parent.identity, path)
	
	# This is a mess.
	if error.is_a?(SyntaxError) and error.path == path
		identity = identity.with_line(error.lineno)
	else
		identity = identity.scoped(error.backtrace_locations)
	end
	
	self.new(identity, path, error)
end

def initialize(identity, path, error)

Initialize a new FileLoadError.

Signature

parameter identity Identity

The identity where the error occurred.

parameter path String

The path to the file.

parameter error Exception

The error that occurred.

Implementation

def initialize(identity, path, error)
	@identity = identity
	@path = path
	@error = error
end

attr :identity

Signature

attribute Identity

The identity where the error occurred.

attr :error

Signature

attribute Exception

The error that occurred.

def leaf?

Signature

returns Boolean

Always returns true, as errors are leaf nodes.

Implementation

def leaf?
	true
end

EMPTY = Hash.new.freeze

An empty hash used for children.

def children

Signature

returns Hash

Always returns an empty hash.

Implementation

def children
	EMPTY
end

def description

Signature

returns String

The file path.

Implementation

def description
	@path
end

def print(output)

Print a representation of this error.

Signature

parameter output Output

The output target.

Implementation

def print(output)
	output.write("file ", :path, @identity)
end

def call(assertions)

Execute this error, recording it in assertions.

Signature

parameter assertions Assertions

The assertions instance.

Implementation

def call(assertions)
	assertions.nested(self, identity: @identity, isolated: true) do |assertions|
		assertions.error!(@error)
	end
end