1 // { dg-options "-Wno-deprecated" }
2 import core.stdc.stdio;
4 // Make sure basic stuff works with future Throwable.message
5 class NoMessage : Throwable
7 @nogc @safe pure nothrow this(string msg, Throwable next = null)
13 class WithMessage : Throwable
15 @nogc @safe pure nothrow this(string msg, Throwable next = null)
20 override const(char)[] message() const
22 return "I have a custom message.";
26 class WithMessageNoOverride : Throwable
28 @nogc @safe pure nothrow this(string msg, Throwable next = null)
33 const(char)[] message() const
35 return "I have a custom message and no override.";
39 class WithMessageNoOverrideAndDifferentSignature : Throwable
41 @nogc @safe pure nothrow this(string msg, Throwable next = null)
46 immutable(char)[] message()
48 return "I have a custom message and I'm nothing like Throwable.message.";
52 void test(Throwable t)
60 fprintf(stderr, "%.*s ", cast(int)e.message.length, e.message.ptr);
66 test(new NoMessage("exception"));
67 test(new WithMessage("exception"));
68 test(new WithMessageNoOverride("exception"));
69 test(new WithMessageNoOverrideAndDifferentSignature("exception"));
70 fprintf(stderr, "\n");