1. /* This file is part of NanoXML.
  2. *
  3. * $Revision: 1.1 $
  4. * $Date: 2007/05/09 15:54:52 $
  5. * $Name: $
  6. *
  7. * Copyright (C) 2000 Marc De Scheemaecker, All Rights Reserved.
  8. *
  9. * This software is provided 'as-is', without any express or implied warranty.
  10. * In no event will the authors be held liable for any damages arising from the
  11. * use of this software.
  12. *
  13. * Permission is granted to anyone to use this software for any purpose,
  14. * including commercial applications, and to alter it and redistribute it
  15. * freely, subject to the following restrictions:
  16. *
  17. * 1. The origin of this software must not be misrepresented; you must not
  18. * claim that you wrote the original software. If you use this software in
  19. * a product, an acknowledgment in the product documentation would be
  20. * appreciated but is not required.
  21. *
  22. * 2. Altered source versions must be plainly marked as such, and must not be
  23. * misrepresented as being the original software.
  24. *
  25. * 3. This notice may not be removed or altered from any source distribution.
  26. */
  27. package nanoxml;
  28. /**
  29. * An XMLParseException is thrown when an error occures while parsing an XML
  30. * string.
  31. * <P>
  32. * $Revision: 1.1 $<BR>
  33. * $Date: 2007/05/09 15:54:52 $<P>
  34. *
  35. * @see nanoxml.XMLElement
  36. *
  37. * @author Marc De Scheemaecker
  38. * <<A HREF="mailto:Marc.DeScheemaecker@advalvas.be"
  39. * >Marc.DeScheemaecker@advalvas.be</A>>
  40. * @version 1.6
  41. */
  42. public class XMLParseException
  43. extends RuntimeException
  44. {
  45. /**
  46. * Where the error occurred, or -1 if the line number is unknown.
  47. */
  48. private int lineNr;
  49. /**
  50. * Creates an exception.
  51. *
  52. * @param tag The name of the tag where the error is located.
  53. * @param message A message describing what went wrong.
  54. */
  55. public XMLParseException(String tag,
  56. String message)
  57. {
  58. super("XML Parse Exception during parsing of "
  59. + ((tag == null) ? "the XML definition" : ("a " + tag + "-tag"))
  60. + ": " + message);
  61. this.lineNr = -1;
  62. }
  63. /**
  64. * Creates an exception.
  65. *
  66. * @param tag The name of the tag where the error is located.
  67. * @param lineNr The number of the line in the input.
  68. * @param message A message describing what went wrong.
  69. */
  70. public XMLParseException(String tag,
  71. int lineNr,
  72. String message)
  73. {
  74. super("XML Parse Exception during parsing of "
  75. + ((tag == null) ? "the XML definition" : ("a " + tag + "-tag"))
  76. + " at line " + lineNr + ": " + message);
  77. this.lineNr = lineNr;
  78. }
  79. /**
  80. * Where the error occurred, or -1 if the line number is unknown.
  81. */
  82. public int getLineNr()
  83. {
  84. return this.lineNr;
  85. }
  86. }