Skip to content

Handle failures in void functions #453

Description

@wprzytula

Background

cass_cluster_set_application_name_n

I wonder if this is the proper way of handling this. It will fail mostly silently - only signal will be an entry in the logs.
Perhaps a panic is warranted here?

Originally posted by @Lorak-mmk in #448 (comment)

Problem

There are quite a lot of public API functions that return void, yet still may fail. Currently, upon error we issue an error! log message, followed by an early return.

@Lorak-mmk correctly noted that this may easily go unnoticed, causing silent bugs. To combat this, he proposed panicking in critical conditions.

Still needs to be settled

It's up to further discussion which error conditions shall be considered critical (and warrant a panic) and which not (so the error log is enough).

For now, we have the following examples of functions falling into each of these categories:

Critical errors

  1. cass_cluster_set_credentials - if it fails, we will likely be unable to connect to the cluster and execute any statements.

Noncritical errors

  1. cass_cluster_set_application_{name,version} - failure to advertise the desired name of the application for the cluster is by far not something that stop driver from doing its work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions