What's the equivalent of std::runtime_error in D?

MorteFeuille123 MorteFeuille123 at jo.rt
Wed Nov 9 13:47:09 UTC 2022


On Wednesday, 9 November 2022 at 12:25:35 UTC, alexandr3000 wrote:
> ```d
> if (vkCreateInstance(&createInfo, null, &instance) != 
> VK_SUCCESS) {
>             ???
> }
> ```

The official error handling system is based on exception, e.g

```d
class VKException : Exception
{
     this(string msg)
     {
         super(msg);
     }
}

void _()
{
    if (vkCreateInstance(&createInfo, null, &instance) != 
VK_SUCCESS) {
       throw new VKException("cannot create VK instance")
    }
}
```

manual : https://dlang.org/spec/errors.html



More information about the Digitalmars-d mailing list