LoginSignup
3
3

More than 5 years have passed since last update.

RubyMotionでエラーが表示されずに落ちるとき、とりあえずやること

Last updated at Posted at 2012-12-26

まだ新しいプロダクトなので仕方ないのかもしれませんが具体的なエラーメッセージなどなくsimulator session ended with errorと吐いてストンと落ちることがあります。

何が原因なのか分からず戸惑うのですが、そういう時はprintデバッグで落ちてるところを見つけて例外を明示的に捕まえてあげれば分かることがあります。

  puts 1
  view.removeFromSuperveiw # <= タイポ orz
  puts 2

この例だと、`removeFromSuperviewをタイポしてて落ちてますが、なかなか分からない(バカ)

  begin
    view.removeFromSuperveiw
  rescue => e
    puts e
  end

こうすると、

(main)> undefined method `removeFromSuperveiw' for #<HogeView:0x9386bf0>

と表示され、( ゚д゚)ハッ! ってなりますね(笑)

2013/06/03 追記

このTipsは1年前のものなので、現在はRubyMotion自体のエラー表示がより具体的になっていて、上記のようなミスはメッセージから分かるようになっているのではないかと思います。

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3