Exceptions in safe D

Juan Campanas johnny at bells.com
Mon Jan 9 13:33:28 PST 2012


On Monday, 9 January 2012 at 21:14:05 UTC, Robert Clipsham wrote:
> Are exceptions in safe D possible? I started trying to make my 
> code @safe (there's no reason why it can't be as far as I'm 
> aware), but I hit the following issue:
>
> ----
> @safe
>
> class MyException : Exception
> {
>    this()
>    {
>        super("");
>    }
> }
>
> void main()
> {
>    throw new MyException("");
> }
> ----
> $ rdmd test.d
> test.d(7): Error: safe function 'this' cannot call system 
> function 'this'
> test.d(13): Error: constructor test.MyException.this () is not 
> callable using argument types (string)
> test.d(13): Error: expected 0 arguments, not 1 for non-variadic 
> function type @safe MyException()
> ----
>
> Is this just unimplemented, is there a workaround, or will this 
> never work?
>
> Thanks,

Why are you calling the MyException constructor with a string 
parameter? Anyways. I think that Exception is not marked as @safe.


More information about the Digitalmars-d-learn mailing list