Exception: Alda::CommandLineError
- Inherits:
-
StandardError
- Object
- StandardError
- Alda::CommandLineError
- Defined in:
- lib/alda-rb/error.rb
Overview
The error is raised when alda
command exits with nonzero status.
Instance Attribute Summary collapse
-
#status ⇒ Object
readonly
The
Process::Status
object representing the status of the process that runsalda
command.
Instance Method Summary collapse
-
#initialize(status, msg = nil) ⇒ CommandLineError
constructor
:call-seq: new(status, msg=nil) -> Alda::CommandLineError.
-
#port ⇒ Object
The port on which the problematic alda server runs.
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 @port = port.to_i else super msg end @status = status end |
Instance Attribute Details
#status ⇒ Object (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
#port ⇒ Object
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 |