Skip to content

Latest commit

 

History

History
35 lines (24 loc) · 1.5 KB

ErrorHandlingAndLogging.md

File metadata and controls

35 lines (24 loc) · 1.5 KB

Error Handling and Logging

Error Handling

DO Throw exceptions to report exceptional failures.

DO Use WIL error handling helpers when handling error code failures (THROW_*(), RETURN_*(), FAIL_FAST_*(), LOG_*()).

Errors

DO Use existing 'HRESULT's if you can. Be careful to pick an existing HRESULT whose symbolic name and message convey the intent and don't mislead the developer, administrator or user.

DO Create new HRESULTs with FACILITY_ITF only if you can't find a reasonable existing one. Any new FACILITY_ITF error MUST use code values in the range 0x0200-0xFFFF. See Codes in FACILITY_ITF for more details.

Logging

DO Rely on WIL error handling helpers to log failures.

DO Use TraceLoggingWrite() to log non-failure information.

DON'T Use WIL's LOG_HR() to report non-failure information. LOG_HR() will FAIL_FAST if handled a SUCCEEDED(hr).

DON'T Define error HRESULTS to pass to LOG_HR() to report non-failure information. Non-error information should be reported via TraceLoggingWrite().