Record Class GeolocationError
java.lang.Object
java.lang.Record
com.vaadin.flow.component.geolocation.GeolocationError
- Record Components:
code- the raw numeric error code as reported by the browser. Applications should usually callerrorCode()instead of comparing this directlydebugInfo- a free-form description of the failure as reported by the browser. Useful for log lines and bug reports — the wording is not standardised across browsers and must not be shown to end users as-is
- All Implemented Interfaces:
GeolocationResult,Serializable
A failed location reading: the request did not produce a
GeolocationPosition.
Delivered to the error consumer of
Geolocation.getPosition(com.vaadin.flow.function.SerializableConsumer, com.vaadin.flow.function.SerializableConsumer)
and held by the GeolocationWatcher.positionSignal() signal. Typical
application code switches on errorCode() to react to the specific
reason:
Geolocation.getPosition(pos -> showOnMap(pos), err -> {
switch (err.errorCode()) {
case PERMISSION_DENIED ->
showExplanation("Location is blocked for this site.");
case POSITION_UNAVAILABLE ->
showRetry("Could not determine your location.");
case TIMEOUT -> showRetry("Location request took too long.");
case UNKNOWN -> showGenericError();
}
});
The raw numeric code() is also exposed for logging and for safe
handling of future browser codes that the enum does not yet know about.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionGeolocationError(int code, String debugInfo) Creates an instance of aGeolocationErrorrecord class. -
Method Summary
Modifier and TypeMethodDescriptionintcode()Returns the value of thecoderecord component.Returns the value of thedebugInforecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the error reason as a typed enum suitable for exhaustiveswitch.final inthashCode()Returns a hash code value for this object.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Method Details
-
errorCode
Returns the error reason as a typed enum suitable for exhaustiveswitch. ReturnsGeolocationErrorCode.UNKNOWNif the browser reports a numeric code this version of Flow does not recognise.- Returns:
- the matching
GeolocationErrorCode, orGeolocationErrorCode.UNKNOWNwhen the rawcode()is not one of the known values
-
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
code
public int code()Returns the value of thecoderecord component.- Returns:
- the value of the
coderecord component
-
debugInfo
Returns the value of thedebugInforecord component.- Returns:
- the value of the
debugInforecord component
-