Skip to content

Commit

Permalink
Add new error types
Browse files Browse the repository at this point in the history
Add ImageFailure and BusyFailure for error reporting.
Rerun elog-errors script to generate error data.

Change-Id: I1f9ec4766d510abe612db2453dcf36325c7dd2f4
Signed-off-by: James Feist <[email protected]>
  • Loading branch information
feistjj committed Jun 30, 2020
1 parent f7a69e1 commit ebcc194
Show file tree
Hide file tree
Showing 3 changed files with 200 additions and 69 deletions.
251 changes: 182 additions & 69 deletions elog-errors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace Image
{
namespace Error
{
struct UnTarFailure;
struct ManifestFileFailure;
} // namespace Error
} // namespace Image
} // namespace Software
Expand All @@ -42,7 +42,7 @@ namespace Image
{
namespace Error
{
struct InternalFailure;
struct ImageFailure;
} // namespace Error
} // namespace Image
} // namespace Software
Expand All @@ -62,7 +62,47 @@ namespace Image
{
namespace Error
{
struct ManifestFileFailure;
struct BusyFailure;
} // namespace Error
} // namespace Image
} // namespace Software
} // namespace openbmc_project
} // namespace xyz
} // namespace sdbusplus

namespace sdbusplus
{
namespace xyz
{
namespace openbmc_project
{
namespace Software
{
namespace Image
{
namespace Error
{
struct UnTarFailure;
} // namespace Error
} // namespace Image
} // namespace Software
} // namespace openbmc_project
} // namespace xyz
} // namespace sdbusplus

namespace sdbusplus
{
namespace xyz
{
namespace openbmc_project
{
namespace Software
{
namespace Image
{
namespace Error
{
struct InternalFailure;
} // namespace Error
} // namespace Image
} // namespace Software
Expand All @@ -89,38 +129,24 @@ namespace _UnTarFailure

struct PATH
{
static constexpr auto str = "PATH=%s";
/*
* We can't use -fsanitize=undefined if we declare a
* 'static constexpr auto str' member, so don't. Instead, open-code the
* mako template lookups.
*/
static constexpr auto str_short = "PATH";
using type = std::tuple<std::decay_t<decltype(str)>, const char*>;
explicit constexpr PATH(const char* a) : _entry(entry(str, a)){};
using type = std::tuple<std::decay_t<decltype("PATH=%s")>, const char*>;
explicit constexpr PATH(const char* a) : _entry(entry("PATH=%s", a)){};
type _entry;
};

} // namespace _UnTarFailure

struct UnTarFailure : public sdbusplus::exception_t
struct UnTarFailure
{
static constexpr auto errName =
"xyz.openbmc_project.Software.Image.UnTarFailure";
static constexpr auto errDesc = "An error occurred during untar.";
static constexpr auto L = level::ERR;
using PATH = _UnTarFailure::PATH;
using metadata_types = std::tuple<PATH>;

const char* name() const noexcept
{
return errName;
}

const char* description() const noexcept
{
return errDesc;
}

const char* what() const noexcept
{
return errName;
}
};

} // namespace Image
Expand All @@ -137,6 +163,7 @@ struct map_exception_type<
{
using type = xyz::openbmc_project::Software::Image::UnTarFailure;
};

} // namespace details

namespace xyz
Expand All @@ -152,38 +179,24 @@ namespace _ManifestFileFailure

struct PATH
{
static constexpr auto str = "PATH=%s";
/*
* We can't use -fsanitize=undefined if we declare a
* 'static constexpr auto str' member, so don't. Instead, open-code the
* mako template lookups.
*/
static constexpr auto str_short = "PATH";
using type = std::tuple<std::decay_t<decltype(str)>, const char*>;
explicit constexpr PATH(const char* a) : _entry(entry(str, a)){};
using type = std::tuple<std::decay_t<decltype("PATH=%s")>, const char*>;
explicit constexpr PATH(const char* a) : _entry(entry("PATH=%s", a)){};
type _entry;
};

} // namespace _ManifestFileFailure

struct ManifestFileFailure : public sdbusplus::exception_t
struct ManifestFileFailure
{
static constexpr auto errName =
"xyz.openbmc_project.Software.Image.ManifestFileFailure";
static constexpr auto errDesc = "An error when reading the Manifest file.";
static constexpr auto L = level::ERR;
using PATH = _ManifestFileFailure::PATH;
using metadata_types = std::tuple<PATH>;

const char* name() const noexcept
{
return errName;
}

const char* description() const noexcept
{
return errDesc;
}

const char* what() const noexcept
{
return errName;
}
};

} // namespace Image
Expand All @@ -200,6 +213,7 @@ struct map_exception_type<sdbusplus::xyz::openbmc_project::Software::Image::
{
using type = xyz::openbmc_project::Software::Image::ManifestFileFailure;
};

} // namespace details

namespace xyz
Expand All @@ -215,39 +229,87 @@ namespace _InternalFailure

struct FAIL
{
static constexpr auto str = "FAIL=%s";
/*
* We can't use -fsanitize=undefined if we declare a
* 'static constexpr auto str' member, so don't. Instead, open-code the
* mako template lookups.
*/
static constexpr auto str_short = "FAIL";
using type = std::tuple<std::decay_t<decltype(str)>, const char*>;
explicit constexpr FAIL(const char* a) : _entry(entry(str, a)){};
using type = std::tuple<std::decay_t<decltype("FAIL=%s")>, const char*>;
explicit constexpr FAIL(const char* a) : _entry(entry("FAIL=%s", a)){};
type _entry;
};

} // namespace _InternalFailure

struct InternalFailure : public sdbusplus::exception_t
struct InternalFailure
{
static constexpr auto errName =
"xyz.openbmc_project.Software.Image.InternalFailure";
static constexpr auto errDesc =
"The operation failed internally during processing the image.";
static constexpr auto L = level::ERR;
using FAIL = _InternalFailure::FAIL;
using metadata_types = std::tuple<FAIL>;
};

} // namespace Image
} // namespace Software
} // namespace openbmc_project
} // namespace xyz

namespace details
{

template <>
struct map_exception_type<
sdbusplus::xyz::openbmc_project::Software::Image::Error::InternalFailure>
{
using type = xyz::openbmc_project::Software::Image::InternalFailure;
};

const char* name() const noexcept
{
return errName;
}
} // namespace details

const char* description() const noexcept
{
return errDesc;
}
namespace xyz
{
namespace openbmc_project
{
namespace Software
{
namespace Image
{
namespace _ImageFailure
{

const char* what() const noexcept
{
return errName;
}
struct FAIL
{
/*
* We can't use -fsanitize=undefined if we declare a
* 'static constexpr auto str' member, so don't. Instead, open-code the
* mako template lookups.
*/
static constexpr auto str_short = "FAIL";
using type = std::tuple<std::decay_t<decltype("FAIL=%s")>, const char*>;
explicit constexpr FAIL(const char* a) : _entry(entry("FAIL=%s", a)){};
type _entry;
};
struct PATH
{
/*
* We can't use -fsanitize=undefined if we declare a
* 'static constexpr auto str' member, so don't. Instead, open-code the
* mako template lookups.
*/
static constexpr auto str_short = "PATH";
using type = std::tuple<std::decay_t<decltype("PATH=%s")>, const char*>;
explicit constexpr PATH(const char* a) : _entry(entry("PATH=%s", a)){};
type _entry;
};

} // namespace _ImageFailure

struct ImageFailure
{
static constexpr auto L = level::ERR;
using FAIL = _ImageFailure::FAIL;
using PATH = _ImageFailure::PATH;
using metadata_types = std::tuple<FAIL, PATH>;
};

} // namespace Image
Expand All @@ -260,10 +322,61 @@ namespace details

template <>
struct map_exception_type<
sdbusplus::xyz::openbmc_project::Software::Image::Error::InternalFailure>
sdbusplus::xyz::openbmc_project::Software::Image::Error::ImageFailure>
{
using type = xyz::openbmc_project::Software::Image::InternalFailure;
using type = xyz::openbmc_project::Software::Image::ImageFailure;
};

} // namespace details

namespace xyz
{
namespace openbmc_project
{
namespace Software
{
namespace Image
{
namespace _BusyFailure
{

struct PATH
{
/*
* We can't use -fsanitize=undefined if we declare a
* 'static constexpr auto str' member, so don't. Instead, open-code the
* mako template lookups.
*/
static constexpr auto str_short = "PATH";
using type = std::tuple<std::decay_t<decltype("PATH=%s")>, const char*>;
explicit constexpr PATH(const char* a) : _entry(entry("PATH=%s", a)){};
type _entry;
};

} // namespace _BusyFailure

struct BusyFailure
{
static constexpr auto L = level::ERR;
using PATH = _BusyFailure::PATH;
using metadata_types = std::tuple<PATH>;
};

} // namespace Image
} // namespace Software
} // namespace openbmc_project
} // namespace xyz

namespace details
{

template <>
struct map_exception_type<
sdbusplus::xyz::openbmc_project::Software::Image::Error::BusyFailure>
{
using type = xyz::openbmc_project::Software::Image::BusyFailure;
};

} // namespace details

} // namespace logging
Expand Down
5 changes: 5 additions & 0 deletions xyz/openbmc_project/Software/Image.errors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@
description: An error when reading the Manifest file.
- name: InternalFailure
description: The operation failed internally during processing the image.
- name: ImageFailure
description: An error occured processing the image.
- name: BusyFailure
description: The device is busy during the update.

13 changes: 13 additions & 0 deletions xyz/openbmc_project/Software/Image.metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,16 @@
meta:
- str: "FAIL=%s"
type: string
- name: ImageFailure
level: ERR
meta:
- str: "FAIL=%s"
type: string
- str: "PATH=%s"
type: string
- name: BusyFailure
level: ERR
meta:
- str: "PATH=%s"
type: string

0 comments on commit ebcc194

Please sign in to comment.