Class GErrorException

All Implemented Interfaces:
Serializable

@NullMarked public class GErrorException extends Exception
A GErrorException is thrown when a GError is returned by native code. See the Gtk documentation on error reporting for details about GError.
See Also:
  • Constructor Details

    • GErrorException

      @Deprecated public GErrorException(MemorySegment gerrorPtr)
      Deprecated.
      Create a GErrorException from a GError memory location that was returned by a native function. Consumes (frees) the GError.
      Parameters:
      gerrorPtr - pointer to a GError in native memory
    • GErrorException

      public GErrorException(GError err)
      Create a GErrorException from a native GError.
      Parameters:
      err - a GError in native memory
    • GErrorException

      public GErrorException(Quark domain, int code, @Nullable String message, @Nullable Object... args)
      Create a GErrorException that can be used to return a GError from a Java callback function to native code. See the Gtk documentation on error reporting for details.
      Parameters:
      domain - the GError error domain
      code - the GError error code
      message - the error message, printf-style formatted
      args - varargs parameters for message format
  • Method Details

    • isErrorSet

      public static boolean isErrorSet(MemorySegment gerrorPtr)
      Check if an error is set.
      Parameters:
      gerrorPtr - pointer to a GError in native memory
      Returns:
      true when an error was set on this pointer
    • take

      public static GErrorException take(MemorySegment gerrorPtr)
      Create a GErrorException from a GError memory location that was returned by a native function. Consumes (frees) the GError.
      Parameters:
      gerrorPtr - pointer to a GError in native memory
      Returns:
      the newly created GErrorException
    • getCode

      public int getCode()
      Get the error code.
      Returns:
      the code of the GError
    • getDomain

      public Quark getDomain()
      Get the error domain.
      Returns:
      The domain of the GError
    • toGError

      public GError toGError()
      Create a new GError instance with the domain, code and message of this GErrorException. The instance will automatically be freed during GC.
      Returns:
      a newly created GError instance
    • toGErrorUnowned

      public GError toGErrorUnowned()
      Create a new GError instance with the domain, code and message of this GErrorException. The instance will not be automatically freed.
      Returns:
      a newly created GError instance