CNTK icon indicating copy to clipboard operation
CNTK copied to clipboard

Completion of error handling

Open elfring opened this issue 10 years ago • 6 comments

Would you like to add more error handling for return values from functions like the following?

elfring avatar Jan 27 '16 09:01 elfring

Yes, this would be better. Contributions would certainly be welcome :)

mahilleb-msft avatar Feb 12 '16 08:02 mahilleb-msft

I suggest to avoid ignorance of return values a bit more.

Are you interested to apply aspect-oriented software development? How do you think about to encapsulate error detection and corresponding exception handling as a reusable aspect in your software?

elfring avatar Feb 12 '16 08:02 elfring

Thanks for the suggestion. However, my hunch is that might be too much for our needs. Minimizing dependencies is also a property to strive for.

In my view, the built-in mechanism of C++ exceptions is perfectly fine for us. CNTK does not really have recoverable errors, with one exception of delay-loading of optional components (e.g. if no CUDA driver is present, we fall back to CPU mode), and the other being simple retry loops for network I/O. All other errors should simply log and fail fast due to our command-line tool nature. In such context, the only reason we ever catch exceptions is to add to their error message and rethrow, and log it at one centralized place.

One problem is how to deal with APIs that don’t throw, like fprintf(). If we need to replace those APIs, I would opt for replacing them with throwing ones. E.g. we already have an fprintf() variant that throws (fprintfOrDie()).

PrintBuiltInfo() is sort of a special case though, since its output is not critical. We could replace all fprintf() calls by fprintfOrDie(), but I am not sure whether the added code complexity (readers may not know what fprintfOrDie() means) is worth it in this particular place, because all we can do is catch an error that means “cannot write to stderr/log” and write that to stderr/log, which we won’t be able to do either.

Thanks!

Frank

From: Markus Elfring [mailto:[email protected]] Sent: Friday, February 12, 2016 0:46 To: Microsoft/CNTK [email protected] Subject: Re: [CNTK] Completion of error handling (#34)

I suggest to avoid ignorance of return valueshttps://na01.safelinks.protection.outlook.com/?url=https%3a%2f%2fcwe.mitre.org%2fdata%2fdefinitions%2f252.html&data=01%7c01%7cfseide%40microsoft.com%7c102fe54619024a54e40a08d33388dec5%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=VFRyM%2fXcoYqlG6l6tEiFc0P8wKlFTnosXWCz1XpgEak%3d a bit more.

Are you interested to apply aspect-oriented software developmenthttps://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2faspectc.org%2f&data=01%7c01%7cfseide%40microsoft.com%7c102fe54619024a54e40a08d33388dec5%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=%2fF%2bP86Ew1ksRvVY7%2bscK7e7eFtTef5Vg9FhiynEBnB4%3d? How do you think about to encapsulate error detection and corresponding exception handling as a reusable aspecthttps://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2fen.wikipedia.org%2fwiki%2fAspect_%2528computer_programming%2529&data=01%7c01%7cfseide%40microsoft.com%7c102fe54619024a54e40a08d33388dec5%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=j7RSL0OsvXpcYdm%2b%2f6l1AeNOu97R%2fkYjK8A7shOT%2bCo%3d in your software?

— Reply to this email directly or view it on GitHubhttps://github.com/Microsoft/CNTK/issues/34#issuecomment-183230653.

frankseide avatar Feb 12 '16 16:02 frankseide

If we need to replace those APIs, I would opt for replacing them with throwing ones.

Would you like to delegate such a software maintenance task to any dedicated development tool?

elfring avatar Feb 12 '16 16:02 elfring

There is a trade-off between dependencies (=effort of getting all dependencies in place, learning curve, version management, IDE integration, and doing so in both Linux and Windows) vs. added value.

My 2 cents would be that probably that trade-off favors simplicity in our case (where most non-throwing APIs are already encapsulated).

From: Markus Elfring [mailto:[email protected]] Sent: Friday, February 12, 2016 8:43 To: Microsoft/CNTK [email protected] Cc: Frank Seide [email protected] Subject: Re: [CNTK] Completion of error handling (#34)

If we need to replace those APIs, I would opt for replacing them with throwing ones.

Would you like to delegate such a software maintenance task to any dedicated development tool?

— Reply to this email directly or view it on GitHubhttps://github.com/Microsoft/CNTK/issues/34#issuecomment-183402062.

frankseide avatar Feb 12 '16 17:02 frankseide

there is ongoing work in this area, but we will not do a complete redesign

wolfma61 avatar Feb 22 '16 16:02 wolfma61