Enum Class GeolocationErrorCode

java.lang.Object
java.lang.Enum<GeolocationErrorCode>
com.vaadin.flow.component.geolocation.GeolocationErrorCode
All Implemented Interfaces:
Serializable, Comparable<GeolocationErrorCode>, Constable

public enum GeolocationErrorCode extends Enum<GeolocationErrorCode>
Typed reasons why a geolocation request can fail.

Returned by GeolocationError.errorCode(). Prefer this enum over comparing raw numbers — exhaustive switch catches missing branches at compile time.

Each constant holds an integer identifier. Applications rarely need to look at code() directly; it is exposed for logging and for round-tripping with GeolocationError.code().

  • Enum Constant Details

    • PERMISSION_DENIED

      public static final GeolocationErrorCode PERMISSION_DENIED
      The user refused to share their location — typically by clicking "Block" on the browser's permission dialog, or by previously denying permission for this origin. Once denied, the browser will keep returning this code until the user re-enables location for the site in their browser settings.
    • POSITION_UNAVAILABLE

      public static final GeolocationErrorCode POSITION_UNAVAILABLE
      The browser tried to determine a position but failed — for example because the device has no GPS signal and no network positioning is available, or because the operating system refused the request. Usually transient; showing a retry button is a reasonable response.
    • TIMEOUT

      public static final GeolocationErrorCode TIMEOUT
      The browser did not produce a position within the time budget set by GeolocationOptions. Either the user is in a difficult-to-locate environment or the timeout was too tight.
    • UNKNOWN

      public static final GeolocationErrorCode UNKNOWN
      The browser reported a numeric error code that this version of Flow does not recognise. GeolocationError.code() still holds the raw value for logging or custom handling.
  • Method Details

    • values

      public static GeolocationErrorCode[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static GeolocationErrorCode valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • code

      public int code()
      Returns the integer identifier of this error code, or -1 for UNKNOWN. Mainly useful for logging or interoperating with GeolocationError.code().
      Returns:
      the numeric code, or -1 for UNKNOWN
    • fromCode

      public static GeolocationErrorCode fromCode(int code)
      Looks up the enum constant for a raw numeric code, returning UNKNOWN if the code is not one this version of Flow recognises. This is how GeolocationError.errorCode() behaves — it maps known codes to constants and surfaces unknown future codes as UNKNOWN rather than throwing.
      Parameters:
      code - the numeric error code
      Returns:
      the matching constant, or UNKNOWN if unrecognised