java.lang.Object
java.lang.Record
org.omnifaces.cdi.ScriptError
- Record Components:
pageURL- The URL of the page where the error occurred, as obtained fromwindow.location.href.errorMessage- The error message, as obtained from the first argument ofwindow.onerroror thereasonof anunhandledrejectionevent.errorName- The error type name (e.g. "TypeError", "ReferenceError", "UnhandledRejection"), as obtained from thenameproperty of theErrorobject, ornullif unavailable.errorStack- The JavaScript stack trace, as obtained from thestackproperty of theErrorobject, ornullif unavailable.sourceURL- The URL of the script file where the error originated, as obtained from the second argument ofwindow.onerror, ornullfor unhandled promise rejections.lineNumber- The line number in the script where the error occurred, as obtained from the third argument ofwindow.onerror, ornullfor unhandled promise rejections.columnNumber- The column number in the script where the error occurred, as obtained from the fourth argument ofwindow.onerror, ornullfor unhandled promise rejections.remoteAddr- The remote address of the client, taking proxy headers (X-Forwarded-Foretc.) into account.userAgent- The User-Agent header of the request.userPrincipal- The name of the authenticated user principal, ornullif not authenticated.
- All Implemented Interfaces:
Serializable
public record ScriptError(String pageURL, String errorMessage, String errorName, String errorStack, String sourceURL, String lineNumber, String columnNumber, String remoteAddr, String userAgent, String userPrincipal)
extends Record
implements Serializable
This CDI event will be fired by ScriptErrorHandler when an uncaught JavaScript error or unhandled promise
rejection is caught in the client. An application scoped CDI bean can @Observes this event.
For detailed usage instructions, see ScriptErrorHandler javadoc.
Usage
@ApplicationScoped
public class ScriptErrorObserver {
private static final Logger logger = Logger.getLogger(ScriptErrorObserver.class.getName());
public void onScriptError(@Observes ScriptError error) {
logger.warning(error.toString());
}
}
- Since:
- 5.2
- Author:
- Bauke Scholtz
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thecolumnNumberrecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the value of theerrorMessagerecord component.Returns the value of theerrorNamerecord component.Returns the value of theerrorStackrecord component.final inthashCode()Returns a hash code value for this object.Returns the value of thelineNumberrecord component.pageURL()Returns the value of thepageURLrecord component.Returns the value of theremoteAddrrecord component.Returns the value of thesourceURLrecord component.final StringtoString()Returns a string representation of this record class.Returns the value of theuserAgentrecord component.Returns the value of theuserPrincipalrecord component.
-
Constructor Details
-
ScriptError
public ScriptError(String pageURL, String errorMessage, String errorName, String errorStack, String sourceURL, String lineNumber, String columnNumber, String remoteAddr, String userAgent, String userPrincipal) Creates an instance of aScriptErrorrecord class.- Parameters:
pageURL- the value for thepageURLrecord componenterrorMessage- the value for theerrorMessagerecord componenterrorName- the value for theerrorNamerecord componenterrorStack- the value for theerrorStackrecord componentsourceURL- the value for thesourceURLrecord componentlineNumber- the value for thelineNumberrecord componentcolumnNumber- the value for thecolumnNumberrecord componentremoteAddr- the value for theremoteAddrrecord componentuserAgent- the value for theuserAgentrecord componentuserPrincipal- the value for theuserPrincipalrecord component
-
-
Method Details
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
pageURL
Returns the value of thepageURLrecord component.- Returns:
- the value of the
pageURLrecord component
-
errorMessage
Returns the value of theerrorMessagerecord component.- Returns:
- the value of the
errorMessagerecord component
-
errorName
Returns the value of theerrorNamerecord component.- Returns:
- the value of the
errorNamerecord component
-
errorStack
Returns the value of theerrorStackrecord component.- Returns:
- the value of the
errorStackrecord component
-
sourceURL
Returns the value of thesourceURLrecord component.- Returns:
- the value of the
sourceURLrecord component
-
lineNumber
Returns the value of thelineNumberrecord component.- Returns:
- the value of the
lineNumberrecord component
-
columnNumber
Returns the value of thecolumnNumberrecord component.- Returns:
- the value of the
columnNumberrecord component
-
remoteAddr
Returns the value of theremoteAddrrecord component.- Returns:
- the value of the
remoteAddrrecord component
-
userAgent
Returns the value of theuserAgentrecord component.- Returns:
- the value of the
userAgentrecord component
-
userPrincipal
Returns the value of theuserPrincipalrecord component.- Returns:
- the value of the
userPrincipalrecord component
-