Exception: Alda::CommandLineError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/alda-rb/error.rb

Overview

The error is raised when alda command exits with nonzero status.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status, msg = nil) ⇒ CommandLineError

:call-seq:

new(status, msg=nil) -> Alda::CommandLineError

Create a Alda::CommandLineError object. status is the status of the process running alda command (can be nil). msg is the output of alda command. #port info is extracted from msg in Alda 1.



31
32
33
34
35
36
37
38
39
# File 'lib/alda-rb/error.rb', line 31

def initialize status, msg = nil
	if Alda.v1? && msg && /^\[(?<port>\d+)\]\sERROR\s(?<message>.*)$/ =~ msg
		super message
		@port = port.to_i
	else
		super msg
	end
	@status = status
end

Instance Attribute Details

#statusObject (readonly)

The Process::Status object representing the status of the process that runs alda command.



8
9
10
# File 'lib/alda-rb/error.rb', line 8

def status
  @status
end

Instance Method Details

#portObject

The port on which the problematic alda server runs. This is only available for Alda 1.

begin
  Alda[port: 1108].play code: 'y'
rescue CommandLineError => e
  e.port # => 1108
end


19
20
21
22
# File 'lib/alda-rb/error.rb', line 19

def port
	Alda::GenerationError.assert_generation [:v1]
	@port
end