Class GErrorException

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
BookmarkFileException, BuilderException, ConstraintVflParserException, ConvertException, CoreException, CssParserException, DBusException, DialogException, DmabufException, DownloadException, Exception, FaviconDatabaseException, FileChooserException, FileException, FileLoaderException, FileSaverException, GLException, IconThemeException, IOChannelException, IOException, JavascriptException, KeyFileException, LayoutDeserializeException, LibraryException, MarkupException, MediaException, ModuleException, NetworkException, NumberParserException, OptionException, ParseException, PixbufException, PluginException, PolicyException, PrintException, PrintException, RecentManagerException, RegexException, ResolverException, ResourceException, ResourceException, SerializationException, SessionException, ShellException, SnapshotException, SpawnException, StreamException, SvgException, TextureException, ThreadException, TLDException, TlsChannelBindingException, TlsException, UriException, URIException, UserContentFilterException, UserMessageException, VariantParseException, VulkanException, WebExtensionException, WebExtensionMatchPatternException, WebsocketException

@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

    • registerErrorDomain

      public static void registerErrorDomain(String domain, Function<GError, ? extends GErrorException> constructor)
      Register an exception constructor for an error domain.
      Parameters:
      domain - the error domain
      constructor - the exception constructor (takes a GError parameter)
    • 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
      API Note:
      Most GErrorException-derived exception classes have a getEnum() method that translates this error code into an enum constant.
    • 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