LoaderError.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright (c) 2021, kleines Filmröllchen <malu.bertsch@gmail.com>.
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/FlyString.h>
  8. namespace Audio {
  9. struct LoaderError {
  10. enum Category : u32 {
  11. // The error category is unknown.
  12. Unknown = 0,
  13. IO,
  14. // The read file doesn't follow the file format.
  15. Format,
  16. // Equivalent to an ASSERT(), except non-crashing.
  17. Internal,
  18. // The loader encountered something in the format that is not yet implemented.
  19. Unimplemented,
  20. };
  21. Category category { Unknown };
  22. // Binary index: where in the file the error occurred.
  23. size_t index { 0 };
  24. FlyString description { String::empty() };
  25. constexpr LoaderError() = default;
  26. LoaderError(Category category, size_t index, FlyString description)
  27. : category(category)
  28. , index(index)
  29. , description(move(description))
  30. {
  31. }
  32. LoaderError(FlyString description)
  33. : description(move(description))
  34. {
  35. }
  36. LoaderError(Category category, FlyString description)
  37. : category(category)
  38. , description(move(description))
  39. {
  40. }
  41. LoaderError(LoaderError&) = default;
  42. LoaderError(LoaderError&&) = default;
  43. };
  44. }