Re: Exception chaining and collectException

2017-08-22 Thread Nemanja Boric via Digitalmars-d
On Tuesday, 22 August 2017 at 07:03:03 UTC, Nemanja Boric wrote: On Monday, 21 August 2017 at 20:15:53 UTC, Ali Çehreli wrote: On 08/19/2017 01:58 PM, Nemanja Boric wrote: C++ also provides a way to inspect if you're in the middle of the stack unwinding caused by an exception, to make this a

Re: Exception chaining and collectException

2017-08-22 Thread Nemanja Boric via Digitalmars-d
On Monday, 21 August 2017 at 20:15:53 UTC, Ali Çehreli wrote: On 08/19/2017 01:58 PM, Nemanja Boric wrote: C++ also provides a way to inspect if you're in the middle of the stack unwinding caused by an exception, to make this a bit more controllable, and I would think we should provide the

Re: Exception chaining and collectException

2017-08-21 Thread Ali Çehreli via Digitalmars-d
On 08/19/2017 01:58 PM, Nemanja Boric wrote: C++ also provides a way to inspect if you're in the middle of the stack unwinding caused by an exception, to make this a bit more controllable, and I would think we should provide the similar primitive:

Re: Exception chaining and collectException

2017-08-21 Thread Ali Çehreli via Digitalmars-d
On 08/17/2017 02:48 PM, H. S. Teoh via Digitalmars-d wrote: > So the question becomes, why does the catch block *not* > catch the instance of MyException when another exception is in transit?! I caught (!) the same or similar behavior last year: https://issues.dlang.org/show_bug.cgi?id=16177

Re: Exception chaining and collectException

2017-08-21 Thread H. S. Teoh via Digitalmars-d
On Sat, Aug 19, 2017 at 08:58:51PM +, Nemanja Boric via Digitalmars-d wrote: > On Friday, 18 August 2017 at 22:51:35 UTC, Walter Bright wrote: > > On 8/18/2017 5:07 AM, Steven Schveighoffer wrote: > > > If we are to remove them, what happens when exceptions would > > > normally chain? > > > >

Re: Exception chaining and collectException

2017-08-19 Thread Nemanja Boric via Digitalmars-d
On Friday, 18 August 2017 at 22:51:35 UTC, Walter Bright wrote: On 8/18/2017 5:07 AM, Steven Schveighoffer wrote: If we are to remove them, what happens when exceptions would normally chain? In C++, throwing an exception while unwinding is a fatal error. Well, you still can throw it, but

Re: Exception chaining and collectException

2017-08-18 Thread Walter Bright via Digitalmars-d
On 8/18/2017 2:09 AM, Don Clugston wrote: I invested quite a lot personally in implementing chained exceptions. But I agree with you. I was actually quite proud that I worked out the nasty corner cases during the initial implementation. As far as I can tell, problems with chained exceptions

Re: Exception chaining and collectException

2017-08-18 Thread Walter Bright via Digitalmars-d
On 8/18/2017 5:07 AM, Steven Schveighoffer wrote: If we are to remove them, what happens when exceptions would normally chain? In C++, throwing an exception while unwinding is a fatal error. More information: https://stackoverflow.com/questions/130117/throwing-exceptions-out-of-a-destructor

Re: Exception chaining and collectException

2017-08-18 Thread Steven Schveighoffer via Digitalmars-d
On Friday, 18 August 2017 at 03:31:38 UTC, Walter Bright wrote: Chained exceptions are a good idea, but are more or less a disaster: 1. No other language does chained exceptions 2. Attempting to hammer D chained exceptions into other language schemes (such as C++) makes for lots of unfun

Re: Exception chaining and collectException

2017-08-18 Thread jmh530 via Digitalmars-d
On Friday, 18 August 2017 at 09:09:47 UTC, Don Clugston wrote: Secondly, exception handling in windows is practically undocumented. Certainly it's not documented in a single place. When I began to implement it, I feared it might be impossible. There isn't any guarantee that exception

Re: Exception chaining and collectException

2017-08-18 Thread Don Clugston via Digitalmars-d
On Friday, 18 August 2017 at 03:31:38 UTC, Walter Bright wrote: Chained exceptions are a good idea, but are more or less a disaster: 1. No other language does chained exceptions 2. Attempting to hammer D chained exceptions into other language schemes (such as C++) makes for lots of unfun

Re: Exception chaining and collectException

2017-08-17 Thread Walter Bright via Digitalmars-d
Chained exceptions are a good idea, but are more or less a disaster: 1. No other language does chained exceptions 2. Attempting to hammer D chained exceptions into other language schemes (such as C++) makes for lots of unfun hours attempting to decode undocumented behavior in those other

Re: Exception chaining and collectException

2017-08-17 Thread H. S. Teoh via Digitalmars-d
Filed a bug: https://issues.dlang.org/show_bug.cgi?id=17760 --T

Re: Exception chaining and collectException

2017-08-17 Thread H. S. Teoh via Digitalmars-d
Here's a reduced example that does not depend on std.exception: --- import std.stdio; class MyException : Exception { this() { super("MYMY"); } } struct S { ~this() { try { throw new MyException; } catch(MyException e) { writefln("Collected MyException: %s", e.msg);

Exception chaining and collectException

2017-08-17 Thread H. S. Teoh via Digitalmars-d
Code: import std.exception : collectException; import std.stdio; class MyException : Exception { this() { super("MYMY"); } } void f() { throw new MyException(); } struct S { ~this() { auto e =