DIP65: Fixing Exception Handling Syntax
Brian Schott via Digitalmars-d
digitalmars-d at puremagic.com
Fri Jul 25 17:14:50 PDT 2014
On Saturday, 26 July 2014 at 00:10:00 UTC, Jakob Ovrum wrote:
> On Friday, 25 July 2014 at 23:12:33 UTC, Walter Bright wrote:
>> On 7/25/2014 3:56 PM, David Nadlinger wrote:
>>> Let's just get rid of "catch {}" which encourages unsafe code
>>> and be done with it.
>>
>> We need to stop breaking code.
>
> Either change breaks code. There's no evidence to support that
> catch{} is more commonly used than catch(MyException!true) et
> al.
If you download D-Scanner and run "dscanner --styleCheck -R
path/to/code" you can easily tell if the LastCatch syntax is
being used. The message you get is "Catching Error or Throwable
is almost always a bad idea."
If you find out that some code IS using this old syntax, this
tool will fix it automatically:
https://gist.github.com/Hackerpilot/5ff6d86f4d22a14a00f3
# Run upgrade
dfix file.d > file.d.fixed
# Check that it worked as expected
meld file.d file.d.fixed
# Overwrite old file
mv file.d.fixed file.d
More information about the Digitalmars-d
mailing list