D-Bus 1.13.14

Data Structures | Typedefs | Functions

Error reporting

D-Bus low-level public API

Error reporting. More...

Data Structures
struct DBusError
Object representing an exception. More...
Typedefs
typedef struct DBusError DBusError
Mostly-opaque type representing an error that occurred.
Functions
void dbus_error_init (DBusError *error)
Initializes a DBusError structure. More...
void dbus_error_free (DBusError *error)
Frees an error that's been set (or just initialized), then reinitializes the error as in dbus_error_init(). More...
void dbus_set_error_const (DBusError *error, const char *name, const char *message)
Assigns an error name and message to a DBusError. More...
void dbus_move_error (DBusError *src, DBusError *dest)
Moves an error src into dest, freeing src and overwriting dest. More...
dbus_bool_t dbus_error_has_name (const DBusError *error, const char *name)
Checks whether the error is set and has the given name. More...
dbus_bool_t dbus_error_is_set (const DBusError *error)
Checks whether an error occurred (the error is set). More...
void dbus_set_error (DBusError *error, const char *name, const char *format,...)
Assigns an error name and message to a DBusError. More...
void _dbus_set_error_valist (DBusError *error, const char *name, const char *format, va_list args)

Detailed Description

Error reporting.

Types and functions related to reporting errors.

In essence D-Bus error reporting works as follows:

DBusError error;

dbus_error_init (&error);

dbus_some_function (arg1, arg2, &error);

if (dbus_error_is_set (&error))

{

​ fprintf (stderr, "an error occurred: %s\n", error.message);

​ dbus_error_free (&error);

}

By convention, all functions allow NULL instead of a DBusError*, so callers who don't care about the error can ignore it.

There are some rules. An error passed to a D-Bus function must always be unset; you can't pass in an error that's already set. If a function has a return code indicating whether an error occurred, and also a DBusError parameter, then the error will always be set if and only if the return code indicates an error occurred. i.e. the return code and the error are never going to disagree.

An error only needs to be freed if it's been set, not if it's merely been initialized.

You can check the specific error that occurred using dbus_error_has_name().

Errors will not be set for programming errors, such as passing invalid arguments to the libdbus API. Instead, libdbus will print warnings, exit on a failed assertion, or even crash in those cases (in other words, incorrect use of the API results in undefined behavior, possibly accompanied by helpful debugging output if you're lucky).

Function Documentation

◆dbus_error_free()

DBUS_EXPORT void dbus_error_free ( DBusError * error )

Frees an error that's been set (or just initialized), then reinitializes the error as in dbus_error_init().

  • Parameters

    ​ errormemory where the error is stored.

Definition at line 211 of file dbus-errors.c.

References DBusRealError::const_message, dbus_error_init(), dbus_free(), DBusRealError::message, DBusRealError::name, and NULL.

Referenced by _dbus_generate_uuid(), _dbus_read_local_machine_uuid(), dbus_get_local_machine_id(), and dbus_move_error().

◆dbus_error_has_name()

DBUS_EXPORT dbus_bool_t dbus_error_has_name ( const DBusError * error,
const char * name
)

Checks whether the error is set and has the given name.

  • Parameters

    ​ errorthe error namethe name

  • Returns

    TRUE if the given named error occurred

Definition at line 302 of file dbus-errors.c.

References _dbus_assert, _dbus_string_equal(), _dbus_string_init_const(), FALSE, DBusError::message, DBusError::name, and NULL.

Referenced by dbus_get_local_machine_id().

◆dbus_error_init()

DBUS_EXPORT void dbus_error_init ( DBusError * error )

Initializes a DBusError structure.

Does not allocate any memory; the error only needs to be freed if it is set at some point.

Definition at line 188 of file dbus-errors.c.

Referenced by _dbus_generate_uuid(), _dbus_listen_tcp_socket(), dbus_error_free(), and dbus_move_error().

◆dbus_error_is_set()

DBUS_EXPORT dbus_bool_t dbus_error_is_set ( const DBusError * error )

Checks whether an error occurred (the error is set).

  • Parameters

    ​ errorthe error object

  • Returns

    TRUE if an error occurred

Definition at line 329 of file dbus-errors.c.

References _dbus_assert, FALSE, DBusError::message, DBusError::name, and NULL.

◆dbus_move_error()

DBUS_EXPORT void dbus_move_error ( DBusError * src,
DBusError * dest
)

Moves an error src into dest, freeing src and overwriting dest.

Both src and dest must be initialized. src is reinitialized to an empty error. dest may not contain an existing error. If the destination is NULL, just frees and reinits the source error.

  • Parameters

    ​ srcthe source error destthe destination error or NULL

Definition at line 279 of file dbus-errors.c.

References dbus_error_free(), and dbus_error_init().

◆dbus_set_error()

DBUS_EXPORT void dbus_set_error ( DBusError * error,
const char * name,
const char * format,
...
)

Assigns an error name and message to a DBusError.

Does nothing if error is NULL.

The format may be NULL, which means a (pretty much useless) default message will be deduced from the name. This is not a good idea, just go ahead and provide a useful error message. It won't hurt you.

If no memory can be allocated for the error message, an out-of-memory error message will be set instead.

  • Parameters

    ​ errorthe error.or NULL namethe error name formatprintf-style format string.

Definition at line 354 of file dbus-errors.c.

References NULL.

Referenced by _dbus_babysitter_set_child_exit_error(), _dbus_become_daemon(), _dbus_change_to_daemon_user(), _dbus_check_dir_is_private_to_user(), _dbus_close(), _dbus_close_socket(), _dbus_command_for_pid(), _dbus_connect_exec(), _dbus_create_directory(), _dbus_create_file_exclusively(), _dbus_delete_directory(), _dbus_delete_file(), _dbus_directory_get_next_file(), _dbus_directory_open(), _dbus_dup(), _dbus_ensure_directory(), _dbus_file_get_contents(), _dbus_generate_random_bytes(), _dbus_generate_uuid(), _dbus_is_console_user(), _dbus_keyring_new_for_credentials(), _dbus_listen_systemd_sockets(), _dbus_listen_tcp_socket(), _dbus_lookup_launchd_socket(), _dbus_make_file_world_readable(), _dbus_message_iter_get_args_valist(), _dbus_read_local_machine_uuid(), _dbus_send_credentials_socket(), _dbus_server_listen_platform_specific(), _dbus_server_new_for_domain_socket(), _dbus_server_new_for_launchd(), _dbus_server_new_for_tcp_socket(), _dbus_set_bad_address(), _dbus_set_socket_nonblocking(), _dbus_socketpair(), _dbus_stat(), _dbus_string_save_to_file(), _dbus_transport_new_for_tcp_socket(), _dbus_transport_open_platform_specific(), _dbus_unix_user_is_at_console(), _dbus_user_database_lookup(), _dbus_user_database_lookup_group(), dbus_connection_send_with_reply_and_block(), dbus_message_demarshal(), dbus_parse_address(), dbus_set_error_from_message(), dbus_signature_validate(), dbus_signature_validate_single(), dbus_try_get_local_machine_id(), dbus_validate_bus_name(), dbus_validate_error_name(), dbus_validate_interface(), dbus_validate_member(), dbus_validate_path(), and dbus_validate_utf8().

◆dbus_set_error_const()

DBUS_EXPORT void dbus_set_error_const ( DBusError * error,
const char * name,
const char * message
)

Assigns an error name and message to a DBusError.

Does nothing if error is NULL. The message may be NULL, which means a default message will be deduced from the name. The default message will be totally useless, though, so using a NULL message is not recommended.

Because this function does not copy the error name or message, you must ensure the name and message are global data that won't be freed. You probably want dbus_set_error() instead, in most cases.

  • Parameters

    ​ errorthe error or NULL namethe error name (not copied!!!) messagethe error message (not copied!!!)

Definition at line 243 of file dbus-errors.c.

References _dbus_assert, DBusError::message, DBusError::name, and NULL.

Referenced by _dbus_get_autolaunch_address(), _dbus_keyring_new_for_credentials(), _dbus_listen_systemd_sockets(), and _dbus_lookup_launchd_socket().


Generated by 1.8.16

Error reporting for dbus的更多相关文章

  1. Eclipse Mars: How to Stop Updating Error Reporting Database

    Eclipse Mars: How to Stop Updating Error Reporting Database I was using Eclise Mars version IDE.. Ev ...

  2. Eclipse Error Reporting Welcome to the Eclipse Error Reporting Service.Do you want to help Eclipse? Enable Disable

    在开发的时候,使用Eclipse IDE,提示如下信息, 这是Eclipse的错误报告,如果不想发送,可以关闭掉,关闭方法: 选择Preferences -> General -> Err ...

  3. 取消Eclipse的Error Reporting

    选择Preferences->General->Error Reporting,Send Mode选择Never send reports

  4. Reporting Services 错误案例一则

    遇到一个有意思的Reporting Services报表的案例,在2015-01-30号的凌晨20分左右的时候,有人发现Reporting Services的速度非常慢,而且最后有抛出异常,当时不知道 ...

  5. Error Handling and Exception

    The default error handling in PHP is very simple.An error message with filename, line number and a m ...

  6. List of 3rd Party .NET UI & Reporting Components

    https://www.codeproject.com/Reference/788434/List-of-rd-Party-NET-UI-Reporting-Components Introducti ...

  7. possible error

    1● regedit 2● path [HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\Windows Error Reporting]       3● 步 ...

  8. 错误:Eclipse老是出现 updating error reports database

    Eclipse 火星版(Mars)一直出现 updating error reports database. Window--->Preferences--->General---> ...

  9. 关于PHP.INI中的错误ERROR报告级别设置

    最近在写php的过程中发现php提示php notice:………………的字样,虽然这个只是php的提示内容,并没有什么大的影响,但是出于安全性和美观方面的考虑,小弟还是想把这个东西去掉. 那么,怎么办 ...

随机推荐

  1. 对CSS3中的transform:Matrix()矩阵的一些理解

    只要有CSS基础的人肯定都知道,我们可以通过transform中的translate,scale,rotate,skew这些方法来控制元素的平移,缩放,旋转,斜切,其实这些方法呢都是为了便于开发者使用 ...

  2. nginx配置之站点服务请求功能配置

    站点服务请求功能配置:html/ nginx.conf中的http{}中的server{}: server { listen 85; server_name localhost; #charset k ...

  3. SSL F5

    应用交付领域经常提到SSL加速,但SSL加速到底是什么意思?SSL加速和F5指什么意思呢?在网上查询和整理了一些关于SSL加速和F5的相关解释,仅供参考:SSL加速:加密套接层协议(简称SSL)是网络 ...

  4. search(16)- elastic4s-内嵌文件:nested and join

    从SQL领域来的用户,对于ES的文件关系维护方式会感到很不习惯.毕竟,ES是分布式数据库只能高效处理独个扁平类型文件,无法支持关系式数据库那样的文件拼接.但是,任何数据库应用都无法避免树型文件关系,因 ...

  5. Linux上,最常用的一批命令解析【10年精选】

    原文链接:https://mp.weixin.qq.com/s/QkqHexs_kOgy_5OwbwyFww 建议点击原文链接查看 不同平台linux客户端连接工具分享: windos终端神器:SSH ...

  6. 【C#图解教程学习笔记】第13章 委托

    13.1 什么是委托 委托是持有一个或多个方法的对象,可将一个方法传递到另一个方法. 委托是用户自定义的引用类型. 13.2 委托概述 类表示的是数据和方法的集合,而委托持有一个或多个方法,以及一系列 ...

  7. CopyOnWriteArrayList(写入并复制) & CountDownLatch(闭锁)

    ConcurrentHashMap: ①Java 5.0 在 java.util.concurrent 包中提供了多种并发容器类来改进同步容器 的性能.② ConcurrentHashMap 同步容器 ...

  8. nvm的安装,安装node,npm

    先说说我为什么使用nvm吧 最近在搞react-native,就碰到了很多坑,其中就有node带来的坑,当你运行react-native start (这是rn启动服务器的命令)就会报一个正则的错误, ...

  9. 【MOOC操作系统】测试题大题-进程调度 先入先服务算法例题 【某多道程序系统供用户使用的主存为100K,磁带机2台,打印机1台,采用可变分区存储管理,静态方式分配外围设备(进程获得所需全部设备才能进入内容),忽略用户作业的I/O时间。采用动态分区、首次匹配法(从低地址区开始)分配主存,一个作业创建一个进程,且运行中不紧缩内存。作业调度采用FCFS算法,在主存中的进程采用剩余时间最短调度算法。】

    分析图: 答案: (1) 8 : 00作业1到达,占有资源并调入主存运行. 8: 20作业2和3同时到达,但作业2因分不到打印机,只能在后备队列等待.作业3资源满足,可进主存运行,并与作业1平分CPU ...

  10. MySQL如何有效的存储IP地址

    前几天,阿淼的一个朋友去面试,他回来告诉我,面试官问他 IP 地址是怎么存在数据库的?他当时也没多想,直接就回答的存字符串啊(心想:这么简单的问题,怕不是看不起我吧) 前面这段权当看看,毕竟 IP地址 ...