question

Upvote
Accepted
100 7 6 7

can I pass NULL for RsslError* when calling rssl functions

If I do not care RsslError, especially when there is not much you can do if function likes rsslReleaseBuffer fails (perhaps it never fail if used correctly).

elektronrefinitiv-realtimeelektron-sdkrrteta-apielektron-transport-api
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
Accepted
1.2k 23 31 44

No unfortunately passing nullptr or NULL will result in a fault when an error occurs and the API attempts to assign a value.

With the Elektron-SDK suite of APIs it is highly recommended to test the return values and at least log the result as it significantly aids in diagnosing faults in production environments. For RsslReleseBuffer the API is used to return an object to a memory pool and thus a failure could mean shortly the pool is exhausted and no new data can be processed.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvote
100 7 6 7

Is RsslError::text always populated in case of error? Obviously RsslError::text is more readable than RsslError::rsslErrorId.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Yes, but it may not be informative, you are recommended to log all available data such as the return code, error code, error id, and error text as appropriate. Beware the value-add libraries have added their own error data types and return codes.

Upvotes
1.2k 23 31 44

Here's one I made earlier,

if (RSSL_RET_SUCCESS != rsslReleaseBuffer (buf, &rssl_err)) {
	LOG(WARNING) << "rsslReleaseBuffer: { "
		  "\"rsslErrorId\": " << rssl_err.rsslErrorId << ""
		", \"sysError\": " << rssl_err.sysError << ""
		", \"text\": \"" << rssl_err.text << "\""
		" }";
}

Other functions sometimes return codes which need helpers to decode,

if (RSSL_RET_SUCCESS != rsslEncodeMsgComplete (⁢, RSSL_TRUE /* commit */)) {
	LOG(ERROR) << "rsslEncodeMsgComplete: { "
		  "\"returnCode\": " << static_cast<signed> (rc) << ""
		", \"enumeration\": \"" << rsslRetCodeToString (rc) << "\""
		", \"text\": \"" << rsslRetCodeInfo (rc) << "\""
		" }";
}

Feel free to take examples from my code, I also created a minimal ostream helpers for some additional types.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.