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.

UserError.java 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * Copyright 2000-2014 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.server;
  17. /**
  18. * <code>UserError</code> is a controlled error occurred in application. User
  19. * errors are occur in normal usage of the application and guide the user.
  20. *
  21. * @author Vaadin Ltd.
  22. * @since 3.0
  23. */
  24. @SuppressWarnings("serial")
  25. public class UserError extends AbstractErrorMessage {
  26. /**
  27. * @deprecated As of 7.0, use {@link ContentMode#TEXT} instead    
  28. */
  29. @Deprecated
  30. public static final ContentMode CONTENT_TEXT = ContentMode.TEXT;
  31. /**
  32. * @deprecated As of 7.0, use {@link ContentMode#PREFORMATTED} instead    
  33. */
  34. @Deprecated
  35. public static final ContentMode CONTENT_PREFORMATTED = ContentMode.PREFORMATTED;
  36. /**
  37. * @deprecated As of 7.0, use {@link ContentMode#HTML} instead    
  38. */
  39. @Deprecated
  40. public static final ContentMode CONTENT_XHTML = ContentMode.HTML;
  41. /**
  42. * Creates a textual error message of level ERROR.
  43. *
  44. * @param textErrorMessage
  45. * the text of the error message.
  46. */
  47. public UserError(String textErrorMessage) {
  48. super(textErrorMessage);
  49. }
  50. /**
  51. * Creates an error message with level and content mode.
  52. *
  53. * @param message
  54. * the error message.
  55. * @param contentMode
  56. * the content Mode.
  57. * @param errorLevel
  58. * the level of error.
  59. */
  60. public UserError(String message, ContentMode contentMode,
  61. ErrorLevel errorLevel) {
  62. super(message);
  63. if (contentMode == null) {
  64. contentMode = ContentMode.TEXT;
  65. }
  66. if (errorLevel == null) {
  67. errorLevel = ErrorLevel.ERROR;
  68. }
  69. setMode(contentMode);
  70. setErrorLevel(errorLevel);
  71. }
  72. }