Exceptions.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. #pragma once
  8. #include <stdexcept>
  9. namespace facebook {
  10. namespace hermes {
  11. namespace inspector {
  12. class AlreadyEnabledException : public std::runtime_error {
  13. public:
  14. AlreadyEnabledException()
  15. : std::runtime_error("can't enable: debugger already enabled") {}
  16. };
  17. class NotEnabledException : public std::runtime_error {
  18. public:
  19. NotEnabledException(const std::string &cmd)
  20. : std::runtime_error("debugger can't perform " + cmd + ": not enabled") {}
  21. };
  22. class InvalidStateException : public std::runtime_error {
  23. public:
  24. InvalidStateException(
  25. const std::string &cmd,
  26. const std::string &curState,
  27. const std::string &expectedState)
  28. : std::runtime_error(
  29. "debugger can't perform " + cmd + ": in " + curState +
  30. ", expected " + expectedState) {}
  31. };
  32. class MultipleCommandsPendingException : public std::runtime_error {
  33. public:
  34. MultipleCommandsPendingException(const std::string &cmd)
  35. : std::runtime_error(
  36. "debugger can't perform " + cmd +
  37. ": a step or resume is already pending") {}
  38. };
  39. } // namespace inspector
  40. } // namespace hermes
  41. } // namespace facebook