[Common] Added macros useful for reporting errors.
authorPawel Andruszkiewicz <p.andruszkie@samsung.com>
Mon, 23 Nov 2015 11:16:29 +0000 (12:16 +0100)
committerPawel Andruszkiewicz <p.andruszkie@samsung.com>
Tue, 24 Nov 2015 07:44:59 +0000 (08:44 +0100)
commit67bca1f889e6b439371c826fef6f413663f74f81
treea010c4f8eac28d3cdfac8c2cc1a743038ad233c7
parentc0268350836c3e771a18a2da88056d3cd31cdde1
[Common] Added macros useful for reporting errors.

[Usage]
///////////////////////
    result = ArchiveManager::getInstance().open(callback);

    if (result) {
        ReportSuccess(out);
    } else {
        LogAndReportError(result, &out);
        LogAndReportError(result, &out, ("Failed to open archive."));
        LogAndReportError(result, &out, ("Failed to open archive: %d.", 11));
    }
///////////////////////
    auto pr1 = LogAndCreateResult(ErrorCode::IO_ERR);
    PlatformResult pr2 = LogAndCreateResult(ErrorCode::IO_ERR);
    return LogAndCreateResult(ErrorCode::IO_ERR);

    auto pr3 = LogAndCreateResult(ErrorCode::IO_ERR, "Not a directory.");
    PlatformResult pr4 = LogAndCreateResult(ErrorCode::IO_ERR, "Not a directory.");
    return LogAndCreateResult(ErrorCode::IO_ERR, "Not a directory.");

    auto pr5 = LogAndCreateResult(ErrorCode::IO_ERR, "Not a directory.", ("Not a directory: reporting IO error"));
    PlatformResult pr6 = LogAndCreateResult(ErrorCode::IO_ERR, "Not a directory.", ("Not a directory: reporting IO error"));
    return LogAndCreateResult(ErrorCode::IO_ERR, "Not a directory.", ("Not a directory: reporting IO error"));

    auto pr7 = LogAndCreateResult(ErrorCode::IO_ERR, "Not a directory.", ("Not a directory: reporting IO error: %d", 33));
    PlatformResult pr8 = LogAndCreateResult(ErrorCode::IO_ERR, "Not a directory.", ("Not a directory: reporting IO error: %d", 33));
    return LogAndCreateResult(ErrorCode::IO_ERR, "Not a directory.", ("Not a directory: reporting IO error: %d", 33));

[Verification] Existing code was not affected.

Change-Id: I8391443ae00c784d89ad25d50de212e26a1bdc07
Signed-off-by: Pawel Andruszkiewicz <p.andruszkie@samsung.com>
src/common/logger.h
src/common/platform_result.cc
src/common/tools.cc