github / github/scientist

All exceptions — including signals — are caught during an observation

Đang mở
#60 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Ruby
Star
7.8k
Fork
505
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

`observation.rb` does this:

```ruby
def initialize(name, experiment, &block)
...

begin
@value = block.call
rescue Object => e
@exception = e
end

...
end
```

Which is a [well](http://daniel.fone.net.nz/blog/2013/05/28/why-you-should-never-rescue-exception-in-ruby/) [documented](http://www.mikeperham.com/2012/03/03/the-perils-of-rescue-exception/) [anti-pattern](https://robots.thoughtbot.com/rescue-standarderror-not-exception). In particular, it means that any signals (eg. ``) will be treated as-if they were just an error in the candidate code (which usually means logging and ignoring).

Note: There's no difference between `rescue Object` and `rescue Exception` because raising a non-exception (eg. a string) will either raise a `` or a ``.

I think the standard pattern — `rescue StandardError` — is correct here. That will catch everything except `SignalException`s and other things which aren't meant to be dealt-with as part of standard error handling.

Although users could filter-out all non-StandardError Exceptions themselves, this feels like a footgun (since signals will be relatively rare — especially in development — most users won't notice any problems until they happen in production).

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu trong observation.rb tại phương thức initialize và kiểm tra rescue quanh block.call. Thay đổi cách xử lý ngoại lệ theo yêu cầu để các signal không bị coi là lỗi của mã ứng viên, sau đó xác minh rằng các lỗi chuẩn vẫn được bắt mà không nuốt các signal.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
ruby
Lĩnh vực
backend
Loại issue
Lỗi
Độ khó
1/5
Thời gian dự kiến
Dưới một giờ
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
52/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.