enhanced_errors 3.0.3 → 3.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/.yardoc/object_types DELETED
Binary file
Binary file
data/.yardoc/proxy_types DELETED
Binary file
@@ -1,47 +0,0 @@
1
- require 'weakref'
2
-
3
- require_relative 'context'
4
-
5
- require 'weakref'
6
- require 'monitor'
7
-
8
- module EnhancedExceptionContext
9
- extend self
10
-
11
- REGISTRY = {}
12
- MUTEX = Monitor.new
13
-
14
- def store_context(exception, context)
15
- MUTEX.synchronize do
16
- REGISTRY[exception.object_id] = { weak_exc: WeakRef.new(exception), context: context }
17
- end
18
- end
19
-
20
- def context_for(exception)
21
- MUTEX.synchronize do
22
- entry = REGISTRY[exception.object_id]
23
- return nil unless entry
24
-
25
- begin
26
- _ = entry[:weak_exc].__getobj__ # ensure exception is still alive
27
- entry[:context]
28
- rescue RefError
29
- # Exception no longer alive, clean up
30
- REGISTRY.delete(exception.object_id)
31
- nil
32
- end
33
- end
34
- end
35
-
36
- def clear_context(exception)
37
- MUTEX.synchronize do
38
- REGISTRY.delete(exception.object_id)
39
- end
40
- end
41
-
42
- def clear_all
43
- MUTEX.synchronize do
44
- REGISTRY.clear
45
- end
46
- end
47
- end