/src/main/java/com/google/ie/common/exception/SystemException.java

http://thoughtsite.googlecode.com/ · Java · 99 lines · 26 code · 15 blank · 58 comment · 1 complexity · 7e8d1f45b171e81a895163863a3947ed MD5 · raw file

  1. /* Copyright 2010 Google Inc.
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS.
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License
  14. */
  15. package com.google.ie.common.exception;
  16. /**
  17. * An Object that extends the RuntimeException object.
  18. * The class is used to wrap the Runtime exceptions that can occur in Ideas
  19. * Exchange Project.
  20. *
  21. * @author asirohi
  22. *
  23. */
  24. public class SystemException extends RuntimeException {
  25. /** A unique identifier for the class */
  26. private static final long serialVersionUID = -5912342563924088330L;
  27. /** An error code that is used to display locale specific error messages */
  28. private String errorCode;
  29. /**
  30. * Constructs a new {@link SystemException} object with the specified detail
  31. * message and an error code.
  32. *
  33. * @param errorCode an error code of the exception.
  34. * @param message the detail message of the exception.
  35. */
  36. public SystemException(String errorCode, String message) {
  37. this(errorCode, message, null);
  38. }
  39. /**
  40. * Constructs a new {@link SystemException} object with the specified error
  41. * code and cause.
  42. *
  43. * @param errorCode an error code of the exception.
  44. * @param message the detail message of the exception.
  45. */
  46. public SystemException(String errorCode, Throwable cause) {
  47. this(errorCode, null, cause);
  48. }
  49. /**
  50. * Constructs a new {@link SystemException} object with the specified error
  51. * code,message and cause.
  52. *
  53. * @param errorCode an error code of the exception.
  54. * @param message the detail message of the exception.
  55. * @param cause an object of class {@link Throwable} representing the cause
  56. * (which is saved for later retrieval by the Throwable.getCause()
  57. * method).
  58. */
  59. public SystemException(String errorCode, String message, Throwable cause) {
  60. super(message, cause);
  61. this.errorCode = errorCode;
  62. }
  63. /**
  64. * Get error code of the.
  65. *
  66. * @return String
  67. */
  68. public String getErrorCode() {
  69. return errorCode;
  70. }
  71. /**
  72. * Set the error code.
  73. *
  74. * @param errorCode
  75. */
  76. public void setErrorCode(String errorCode) {
  77. this.errorCode = errorCode;
  78. }
  79. @Override
  80. public String toString() {
  81. String s = super.toString();
  82. return (errorCode != null) ? (errorCode + " : " + s) : s;
  83. }
  84. }