You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

XhrConnectionError.java 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * Copyright 2000-2018 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.client.communication;
  17. import com.google.gwt.http.client.Request;
  18. import com.google.gwt.http.client.Response;
  19. import elemental.json.JsonObject;
  20. /**
  21. * XhrConnectionError provides detail about an error which occurred during
  22. * an XHR request to the server.
  23. *
  24. * @since 7.6
  25. * @author Vaadin Ltd
  26. */
  27. public class XhrConnectionError {
  28. private Throwable exception;
  29. private Request request;
  30. private Response response;
  31. private JsonObject payload;
  32. /**
  33. * Constructs an event from the given request, payload and exception.
  34. *
  35. * @param request
  36. * the request which failed
  37. * @param payload
  38. * the payload which was going to the server
  39. * @param exception
  40. * the exception describing the problem
  41. */
  42. public XhrConnectionError(Request request, JsonObject payload,
  43. Throwable exception) {
  44. this.request = request;
  45. this.exception = exception;
  46. this.payload = payload;
  47. }
  48. /**
  49. * Constructs an event from the given request, response and payload.
  50. *
  51. * @param request
  52. * the request which failed
  53. * @param payload
  54. * the payload which was going to the server
  55. * @param response
  56. * the response for the request
  57. */
  58. public XhrConnectionError(Request request, JsonObject payload,
  59. Response response) {
  60. this.request = request;
  61. this.response = response;
  62. this.payload = payload;
  63. }
  64. /**
  65. * Returns the exception which caused the problem, if available.
  66. *
  67. * @return the exception which caused the problem, or null if not available
  68. */
  69. public Throwable getException() {
  70. return exception;
  71. }
  72. /**
  73. * Returns the request for which the problem occurred.
  74. *
  75. * @return the request where the problem occurred
  76. */
  77. public Request getRequest() {
  78. return request;
  79. }
  80. /**
  81. * Returns the received response, if available.
  82. *
  83. * @return the received response, or null if not available
  84. */
  85. public Response getResponse() {
  86. return response;
  87. }
  88. /**
  89. * Returns the payload which was sent to the server.
  90. *
  91. * @return the payload which was sent, never null
  92. */
  93. public JsonObject getPayload() {
  94. return payload;
  95. }
  96. }