Bug 8398 – enforceEx cannot be used with OutOfMemoryError
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-07-18T02:50:00Z
Last change time
2012-07-22T02:07:05Z
Assigned to
nobody
Creator
jakobovrum
Comments
Comment #0 by jakobovrum — 2012-07-18T02:50:51Z
This idiom would be quite useful to have:
auto data = enforceEx!OutOfMemoryError(malloc(size));
However, OutOfMemoryError only provides this constructor:
this(string file = __FILE__, size_t line = __LINE__, Throwable next = null )
I think enforceEx is at fault here, not OutOfMemoryError. The non-deprecated overload of enforceEx should allow for constructors of the above form, requiring the file and line but providing its own messsage.