Class: Fairy::BBlock

Inherits:
Object
  • Object
show all
Defined in:
lib/fairy/share/block-source.rb

Instance Method Summary collapse

Constructor Details

#initialize(block_source, context, exception_handler) ⇒ BBlock

Returns a new instance of BBlock.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/fairy/share/block-source.rb', line 58

def initialize(block_source, context, exception_handler)
  @block_source = block_source.dc_deep_copy
  @context = context
  @exception_handler = exception_handler

  match = /^(.*):([0-9]+)/.match(@block_source.backtrace.first)
  begin
  @block = eval("proc{#{@block_source.source}}", context.binding, match[1], match[2].to_i)
  rescue ScriptError
  Log::warn(self) do |sio|
    sio.puts "Warn: Exception raised:"
    sio.puts $!
    for l in $@
 sio.puts "\t#{l}"
    end
  end
  bt = @block_source.backtrace.dc_deep_copy
  $!.set_backtrace(bt)
  @exception_handler.handle_exception($!)
  # ここの処理がイマイチ
  end
end

Instance Method Details

#yield18(*args) ⇒ Object Also known as: yield



201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# File 'lib/fairy/share/block-source.rb', line 201

def yield18(*args)
  begin
  if args.size == 1 && args.first.kind_of?(Array)
    args = args.first.to_a
  end
  $stdout.replace_stdout do
    @block.call(*args)
  end

  rescue LocalJumpError, @context.class::GlobalBreak
  Log::debug(self, "CAUGHT GlobalBreak")
  @exception_handler.global_break

  rescue Exception
  Log::warn(self) do |sio|
    sio.puts "Warn: Exception raised:"
    sio.puts $!
    for l in $@
 sio.puts "\t#{l}"
    end
  end
  bt = $!.backtrace
  bt = bt.select{|l| /fairy.*(share|job|backend|node|processor|controller)|deep-connect|__FORWARDABLE__|bin.*processor/ !~ l} unless CONF.DEBUG_FULL_BACKTRACE
  bt.first.sub!("bind", @block_source.caller_method)
  bt.push *@block_source.backtrace.dc_deep_copy
  $!.set_backtrace(bt)

  @exception_handler.handle_exception($!)
  end
end

#yield19(*args) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/fairy/share/block-source.rb', line 81

def yield19(*args)
  begin
  $stdout.replace_stdout do
    @block.yield(*args)
  end

  rescue LocalJumpError, 
    @context.class::GlobalBreak, 
    @context.class::GlobalBreakFromOther
  Log::debug(self, "CAUGHT GlobalBreak")
  raise

  rescue
  if @context.IGNORE_EXCEPTION
    Log::warn(self, "IGNORE_EXCEPTON!!")
    Log::warn(self, "Block Parameters: #{args.inspect}")
  end
  Log::warn(self) do |sio|
    sio.puts "Warn: Exception raised:"
    sio.puts $!
    for l in $@
 sio.puts "\t#{l}"
    end
  end

  if @context.IGNORE_EXCEPTION
    return Import::TOKEN_NULLVALUE
  else
    bt = $!.backtrace
    bt = bt.select{|l| /fairy.*(share|job|backend|node|processor|controller)|deep-connect|__FORWARDABLE__|bin.*processor/ !~ l} unless CONF.DEBUG_FULL_BACKTRACE
    unless bt.empty?
 bt.first.sub!("bind", @block_source.caller_method)
    end
    bt.push *@block_source.backtrace.dc_deep_copy
    $!.set_backtrace(bt)

    @exception_handler.handle_exception($!)
  end

  rescue Exception
  Log::warn(self) do |sio|
    sio.puts "Warn: Exception raised:"
    sio.puts $!
    for l in $@
 sio.puts "\t#{l}"
    end
  end
  bt = $!.backtrace
  bt = bt.select{|l| /fairy.*(share|job|backend|node|processor|controller)|deep-connect|__FORWARDABLE__|bin.*processor/ !~ l} unless CONF.DEBUG_FULL_BACKTRACE
  unless bt.empty?
    bt.first.sub!("bind", @block_source.caller_method)
  end
  bt.push *@block_source.backtrace.dc_deep_copy
  $!.set_backtrace(bt)

  @exception_handler.handle_exception($!)
  end
end

#yield19_no_use_stdout(*args) ⇒ Object



140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# File 'lib/fairy/share/block-source.rb', line 140

def yield19_no_use_stdout(*args)
  begin

  @block.yield(*args)

  rescue LocalJumpError, 
    @context.class::GlobalBreak,
    @context.class::GlobalBreakFromOther
  Log::debug(self, "CAUGHT GlobalBreak")
  raise
# @exception_handler.global_break

  rescue
  if @context.IGNORE_EXCEPTION
    Log::warn(self, "IGNORE_EXCEPTON!!")
    Log::warn(self, "Block Parameters: #{args.inspect}")
  end
  Log::warn(self) do |sio|
    sio.puts "Warn: Exception raised:"
    sio.puts $!
    for l in $@
 sio.puts "\t#{l}"
    end
  end

  if @context.IGNORE_EXCEPTION
    return Import::TOKEN_NULLVALUE
  else
    bt = $!.backtrace
    bt = bt.select{|l| /fairy.*(share|job|backend|node|processor|controller)|deep-connect|__FORWARDABLE__|bin.*processor/ !~ l} unless CONF.DEBUG_FULL_BACKTRACE
    unless bt.empty?
 bt.first.sub!("bind", @block_source.caller_method)
    end
    bt.first.sub!("bind", @block_source.caller_method)
    bt.push *@block_source.backtrace.dc_deep_copy
    $!.set_backtrace(bt)

    @exception_handler.handle_exception($!)
  end

  rescue Exception
  Log::warn(self) do |sio|
    sio.puts "Warn: Exception raised:"
    sio.puts $!
    for l in $@
 sio.puts "\t#{l}"
    end
  end
  bt = $!.backtrace
  bt = bt.select{|l| /fairy.*(share|job|backend|node|processor|controller)|deep-connect|__FORWARDABLE__|bin.*processor/ !~ l} unless CONF.DEBUG_FULL_BACKTRACE
  bt.first.sub!("bind", @block_source.caller_method)
  unless bt.empty?
    bt.first.sub!("bind", @block_source.caller_method)
  end
  bt.push *@block_source.backtrace.dc_deep_copy
  $!.set_backtrace(bt)

  @exception_handler.handle_exception($!)
  end
end