Stay organized with collections
Save and categorize content based on your preferences.
ErrorListener
public
interface
ErrorListener
javax.xml.transform.ErrorListener
|
To provide customized error handling, implement this interface and
use the setErrorListener
method to register an instance of the
implementation with the Transformer
. The
Transformer
then reports all errors and warnings through this
interface.
If an application does not register its own custom
ErrorListener
, the default ErrorListener
is used which reports all warnings and errors to System.err
and does not throw any Exception
s.
Applications are strongly encouraged to register and use
ErrorListener
s that insure proper behavior for warnings and
errors.
For transformation errors, a Transformer
must use this
interface instead of throwing an Exception
: it is up to the
application to decide whether to throw an Exception
for
different types of errors and warnings. Note however that the
Transformer
is not required to continue with the transformation
after a call to fatalError(javax.xml.transform.TransformerException)
.
Transformer
s may use this mechanism to report XML parsing
errors as well as transformation errors.
Summary
Public methods
public abstract void error (TransformerException exception)
Receive notification of a recoverable error.
The transformer must continue to try and provide normal transformation
after invoking this method. It should still be possible for the
application to process the document through to the end if no other errors
are encountered.
Parameters |
exception |
TransformerException : The error information encapsulated in a
transformer exception. |
public abstract void fatalError (TransformerException exception)
Receive notification of a non-recoverable error.
The Transformer
must continue to try and provide normal
transformation after invoking this method. It should still be possible for the
application to process the document through to the end if no other errors
are encountered, but there is no guarantee that the output will be
useable.
Parameters |
exception |
TransformerException : The error information encapsulated in a
TransformerException . |
public abstract void warning (TransformerException exception)
Receive notification of a warning.
Transformer
can use this method to report
conditions that are not errors or fatal errors. The default behavior
is to take no action.
After invoking this method, the Transformer must continue with
the transformation. It should still be possible for the
application to process the document through to the end.
Parameters |
exception |
TransformerException : The warning information encapsulated in a
transformer exception. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# ErrorListener\n\nAdded in [API level 8](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\nErrorListener\n=============\n\n\n`\npublic\n\n\ninterface\nErrorListener\n`\n\n\n`\n\n\n`\n\n|-----------------------------------|\n| javax.xml.transform.ErrorListener |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\n\u003cbr /\u003e\n\nTo provide customized error handling, implement this interface and\nuse the `setErrorListener` method to register an instance of the\nimplementation with the [Transformer](/reference/javax/xml/transform/Transformer). The\n`Transformer` then reports all errors and warnings through this\ninterface.\n\nIf an application does *not* register its own custom\n`ErrorListener`, the default `ErrorListener`\nis used which reports all warnings and errors to `System.err`\nand does not throw any `Exception`s.\nApplications are *strongly* encouraged to register and use\n`ErrorListener`s that insure proper behavior for warnings and\nerrors.\n\nFor transformation errors, a `Transformer` must use this\ninterface instead of throwing an `Exception`: it is up to the\napplication to decide whether to throw an `Exception` for\ndifferent types of errors and warnings. Note however that the\n`Transformer` is not required to continue with the transformation\nafter a call to [fatalError(javax.xml.transform.TransformerException)](/reference/javax/xml/transform/ErrorListener#fatalError(javax.xml.transform.TransformerException)).\n\n`Transformer`s may use this mechanism to report XML parsing\nerrors as well as transformation errors.\n\n\u003cbr /\u003e\n\nSummary\n-------\n\n| ### Public methods ||\n|------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract void` | ` `[error](/reference/javax/xml/transform/ErrorListener#error(javax.xml.transform.TransformerException))`(`[TransformerException](/reference/javax/xml/transform/TransformerException)` exception) ` Receive notification of a recoverable error. |\n| ` abstract void` | ` `[fatalError](/reference/javax/xml/transform/ErrorListener#fatalError(javax.xml.transform.TransformerException))`(`[TransformerException](/reference/javax/xml/transform/TransformerException)` exception) ` \u003cbr /\u003e Receive notification of a non-recoverable error. |\n| ` abstract void` | ` `[warning](/reference/javax/xml/transform/ErrorListener#warning(javax.xml.transform.TransformerException))`(`[TransformerException](/reference/javax/xml/transform/TransformerException)` exception) ` Receive notification of a warning. |\n\nPublic methods\n--------------\n\n### error\n\nAdded in [API level 8](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract void error (TransformerException exception)\n```\n\nReceive notification of a recoverable error.\n\nThe transformer must continue to try and provide normal transformation\nafter invoking this method. It should still be possible for the\napplication to process the document through to the end if no other errors\nare encountered.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Parameters ||\n|-------------|-----------------------------------------------------------------------------------------------|\n| `exception` | `TransformerException`: The error information encapsulated in a transformer exception. \u003cbr /\u003e |\n\n| Throws ||\n|-----------------------------------------------------------------------------|---------------------------------------------------------------|\n| [TransformerException](/reference/javax/xml/transform/TransformerException) | if the application chooses to discontinue the transformation. |\n\n**See also:**\n\n- [TransformerException](/reference/javax/xml/transform/TransformerException) \n\n### fatalError\n\nAdded in [API level 8](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract void fatalError (TransformerException exception)\n```\n\n\u003cbr /\u003e\n\nReceive notification of a non-recoverable error.\n\nThe `Transformer` must continue to try and provide normal\ntransformation after invoking this method. It should still be possible for the\napplication to process the document through to the end if no other errors\nare encountered, but there is no guarantee that the output will be\nuseable.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Parameters ||\n|-------------|------------------------------------------------------------------------------------------------|\n| `exception` | `TransformerException`: The error information encapsulated in a `TransformerException`. \u003cbr /\u003e |\n\n| Throws ||\n|-----------------------------------------------------------------------------|---------------------------------------------------------------|\n| [TransformerException](/reference/javax/xml/transform/TransformerException) | if the application chooses to discontinue the transformation. |\n\n**See also:**\n\n- [TransformerException](/reference/javax/xml/transform/TransformerException) \n\n### warning\n\nAdded in [API level 8](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract void warning (TransformerException exception)\n```\n\nReceive notification of a warning.\n\n[Transformer](/reference/javax/xml/transform/Transformer) can use this method to report\nconditions that are not errors or fatal errors. The default behavior\nis to take no action.\n\nAfter invoking this method, the Transformer must continue with\nthe transformation. It should still be possible for the\napplication to process the document through to the end.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Parameters ||\n|-------------|-------------------------------------------------------------------------------------------------|\n| `exception` | `TransformerException`: The warning information encapsulated in a transformer exception. \u003cbr /\u003e |\n\n| Throws ||\n|-----------------------------------------------------------------------------|---------------------------------------------------------------|\n| [TransformerException](/reference/javax/xml/transform/TransformerException) | if the application chooses to discontinue the transformation. |\n\n**See also:**\n\n- [TransformerException](/reference/javax/xml/transform/TransformerException)"]]