ExceptionBuilder.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. namespace Xilium.CefGlue
  2. {
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Globalization;
  6. using System.Text;
  7. internal static class ExceptionBuilder
  8. {
  9. public static CefVersionMismatchException RuntimeVersionBuildRevisionMismatch(int actual, int expected)
  10. {
  11. return new CefVersionMismatchException(string.Format(CultureInfo.InvariantCulture,
  12. "CEF runtime version mismatch: loaded revision {0}, but supported {1}.",
  13. actual,
  14. expected
  15. ));
  16. }
  17. public static CefVersionMismatchException RuntimeVersionApiHashMismatch(string actual, string expected, string expectedVersion)
  18. {
  19. return new CefVersionMismatchException(string.Format(CultureInfo.InvariantCulture,
  20. "CEF runtime version mismatch: loaded version API hash \"{0}\", but supported \"{1}\" ({2}).",
  21. actual,
  22. expected,
  23. expectedVersion
  24. ));
  25. }
  26. public static Exception CefRuntimeAlreadyInitialized()
  27. {
  28. return new InvalidOperationException("CEF runtime already initialized.");
  29. }
  30. public static Exception CefRuntimeNotInitialized()
  31. {
  32. return new InvalidOperationException("CEF runtime is not initialized.");
  33. }
  34. public static Exception CefRuntimeFailedToInitialize()
  35. {
  36. return new InvalidOperationException("Failed to initialize CEF runtime.");
  37. }
  38. public static Exception UnsupportedPlatform()
  39. {
  40. return new InvalidOperationException("Unsupported platform.");
  41. }
  42. public static Exception InvalidSelfReference()
  43. {
  44. return new InvalidOperationException("Invalid self reference.");
  45. }
  46. public static Exception FailedToCreateBrowser(int errorCode)
  47. {
  48. return new InvalidOperationException($"Failed to create browser with error code ({errorCode})");
  49. }
  50. public static Exception ObjectDisposed()
  51. {
  52. return new InvalidOperationException("Object disposed.");
  53. }
  54. public static Exception ObjectNotFound()
  55. {
  56. return new InvalidOperationException("Failed to map pointer to object.");
  57. }
  58. }
  59. }