Kanzi Framework  3.9.0
Kanzi Engine API
kzs_error.hpp File Reference

Error handling functions. More...

#include <boost/preprocessor/cat.hpp>
#include <kanzi/core/debug/assert.hpp>
#include <kanzi/core/legacy/kzs_types.hpp>
#include <kanzi/core/cpp/string_view.hpp>

Namespaces

 kanzi
 Easing functions that require external dependencies for calculation.
 

Macros

#define KZ_APPEND_MESSAGE_TO_STRING_LOGGER_INTERNAL(logger, logMessage)
 
#define KZ_LOG_CATEGORY_LEGACY_EXCEPTIONS
 
#define KZ_REPORT_ERROR_INTERNAL(new_error, logMessage)
 
#define KZ_REPORT_EXCEPTION_INTERNAL(error, logMessage)
 
#define KZ_UNIQUE_NAME_INTERNAL(name)
 
#define KZS_ERROR_ARRAY_OUT_OF_BOUNDS
 Trying to access array with invalid index. More...
 
#define KZS_ERROR_ASSERTION_FAILED
 Assertion failed. More...
 
#define KZS_ERROR_ENUM_OUT_OF_RANGE
 Invalid value for enum. More...
 
#define KZS_ERROR_ILLEGAL_ARGUMENT
 An argument was invalid for the given context. More...
 
#define KZS_ERROR_ILLEGAL_OPERATION
 Trying to perform illegal operation. More...
 
#define KZS_ERROR_INVALID_STATE
 Program is in invalid state. More...
 
#define KZS_ERROR_MALFORMED_DATA
 Data is malformed. More...
 
#define KZS_ERROR_NOT_IMPLEMENTED_YET
 Functionality is not yet implemented. More...
 
#define KZS_EXCEPTION_MESSAGE_MAXIMUM_LENGTH
 Maximum length of exception. More...
 
#define KZS_NOT_IMPLEMENTED_YET
 Macro to use to indicate that some code is not yet implemented. More...
 
#define KZS_NOT_IMPLEMENTED_YET_ERROR
 Macro to use to indicate and throw error that some code is not yet implemented. More...
 
#define KZS_NOT_IMPLEMENTED_YET_ERROR_TEXT(message)
 Macro to use to indicate and throw error with an explanation, that some code is not yet implemented. More...
 
#define KZS_SUCCESS
 Success code. More...
 
#define kzsErrorForward(error)
 Return from the function with the given error code, if it is one. More...
 
#define kzsErrorIf(error)
 Test if the given error is an error. More...
 
#define kzsErrorLog(errorCode, message)
 Logs the given error code with given message. More...
 
#define kzsErrorSubstitute(error, new_error, logMessage)
 Return from the function with the given new error code, if the given old code is also an error. More...
 
#define kzsErrorTest(test, new_error, logMessage)
 Return from the function with the given error code, if the test is false. More...
 
#define kzsErrorThrow(new_error, logMessage)
 Return from the function with the given error code. More...
 
#define kzsExceptionCatch(exception, exception_code)
 Test if the given exception matches the specified exception code. More...
 
#define kzsExceptionCatchAll(exception)
 Test if the given exception is an actual exception and not success or error. More...
 
#define kzsExceptionForward(exception)
 Return from the function with the given exception or error code, if it is one. More...
 
#define kzsExceptionForwardAsError(exception, new_error, logMessage)
 If the given exception code is an error, pass it forward. More...
 
#define kzsExceptionLog(errorCode, message)
 Logs exception with given error code with given message. More...
 
#define kzsExceptionRethrow(param_exception)
 Return from the function with the given exception code. More...
 
#define kzsExceptionSubstitute(error, new_exception, logMessage)
 Return from the function with the given new exception code, if the given old code is also an exception. More...
 
#define kzsExceptionTest(test, new_exception, logMessage)
 Return from the function with the given exception code, if the test is false. More...
 
#define kzsExceptionThrow(new_exception, logMessage)
 Return from the function with the given exception code. More...
 
#define kzsSuccess()
 Return from the function without any error code. More...
 

Typedefs

typedef int kzsError
 Error code type definition. More...
 
typedef void(* KzsErrorCallback) (kzsError errorCode, kzString message)
 Callback that is triggered in error situations. More...
 
typedef int kzsException
 Exception code type definition, extends error. More...
 
typedef void(* KzsExceptionCallback) (kzsError errorCode, kzString message)
 Callback that is triggered in exception situations. More...
 

Functions

kzsError kzsErrorDeinitializeThread (void)
 De-initializes error handling for thread. More...
 
kzsError kzsErrorGetLastErrorCode ()
 Gets last error code. More...
 
kzString kzsErrorGetLastErrorMessage ()
 Gets last error message stored in a global buffer or empty string if there are no errors have being reported yet. More...
 
kzString kzsErrorGetLastExceptionMessage ()
 Gets the last exception message for the thread or empty string if there are no exceptions have being reported yet. More...
 
kzString kzsErrorGetLastExceptionMessage (kzString fallbackMessage)
 Gets the last exception message for the thread. More...
 
kzsError kzsErrorInitialize (void)
 Initialize a global variable for error message storage. More...
 
kzsError kzsErrorInitializeThread (kzMutableString storage)
 Initializes error handling for thread. More...
 
void kzsErrorSetErrorCallback (KzsErrorCallback callback)
 Sets error callback. More...
 
void kzsErrorSetExceptionCallback (KzsExceptionCallback callback)
 Sets exception callback. More...
 
void kzsErrorThrow_private (kzsError error, kzString message)
 Wrapper for kzsErrorThrow() to share more code. More...
 
kzsError kzsErrorUninitialize (void)
 De-initialize a global variable for error message storage. More...
 
void kzsExceptionThrow_private (kzsError error, kzString message)
 Wrapper for kzsExceptionThrow() to share more code. More...
 
void kzsStoreErrorMessage (kzsError errorCode, kzString message)
 Stores error message in global storage area. More...
 
void kzsStoreExceptionMessage (kzString message)
 Stores exception message in per-thread data area. More...
 

Detailed Description

Error handling functions.

Copyright 2008-2017 by Rightware. All rights reserved.

Macro Definition Documentation

◆ KZS_EXCEPTION_MESSAGE_MAXIMUM_LENGTH

#define KZS_EXCEPTION_MESSAGE_MAXIMUM_LENGTH

Maximum length of exception.

◆ KZS_SUCCESS

#define KZS_SUCCESS

Success code.

No error.

◆ KZS_ERROR_ASSERTION_FAILED

#define KZS_ERROR_ASSERTION_FAILED

Assertion failed.

◆ KZS_ERROR_NOT_IMPLEMENTED_YET

#define KZS_ERROR_NOT_IMPLEMENTED_YET

Functionality is not yet implemented.

◆ KZS_ERROR_ENUM_OUT_OF_RANGE

#define KZS_ERROR_ENUM_OUT_OF_RANGE

Invalid value for enum.

◆ KZS_ERROR_ILLEGAL_OPERATION

#define KZS_ERROR_ILLEGAL_OPERATION

Trying to perform illegal operation.

◆ KZS_ERROR_ILLEGAL_ARGUMENT

#define KZS_ERROR_ILLEGAL_ARGUMENT

An argument was invalid for the given context.

◆ KZS_ERROR_MALFORMED_DATA

#define KZS_ERROR_MALFORMED_DATA

Data is malformed.

◆ KZS_ERROR_ARRAY_OUT_OF_BOUNDS

#define KZS_ERROR_ARRAY_OUT_OF_BOUNDS

Trying to access array with invalid index.

◆ KZS_ERROR_INVALID_STATE

#define KZS_ERROR_INVALID_STATE

Program is in invalid state.

◆ KZ_LOG_CATEGORY_LEGACY_EXCEPTIONS

#define KZ_LOG_CATEGORY_LEGACY_EXCEPTIONS

◆ kzsSuccess

#define kzsSuccess ( )

Return from the function without any error code.

◆ KZ_UNIQUE_NAME_INTERNAL

#define KZ_UNIQUE_NAME_INTERNAL (   name)

◆ KZ_APPEND_MESSAGE_TO_STRING_LOGGER_INTERNAL

#define KZ_APPEND_MESSAGE_TO_STRING_LOGGER_INTERNAL (   logger,
  logMessage 
)

◆ KZ_REPORT_ERROR_INTERNAL

#define KZ_REPORT_ERROR_INTERNAL (   new_error,
  logMessage 
)

◆ KZ_REPORT_EXCEPTION_INTERNAL

#define KZ_REPORT_EXCEPTION_INTERNAL (   error,
  logMessage 
)

◆ kzsErrorThrow

#define kzsErrorThrow (   new_error,
  logMessage 
)

Return from the function with the given error code.

◆ kzsExceptionThrow

#define kzsExceptionThrow (   new_exception,
  logMessage 
)

Return from the function with the given exception code.

◆ kzsExceptionRethrow

#define kzsExceptionRethrow (   param_exception)

Return from the function with the given exception code.

◆ kzsErrorTest

#define kzsErrorTest (   test,
  new_error,
  logMessage 
)

Return from the function with the given error code, if the test is false.

Otherwise continue.

◆ kzsExceptionTest

#define kzsExceptionTest (   test,
  new_exception,
  logMessage 
)

Return from the function with the given exception code, if the test is false.

Otherwise continue.

◆ kzsErrorForward

#define kzsErrorForward (   error)

Return from the function with the given error code, if it is one.

If the error code is an exception, the code may or may not return (use kzsExceptionForward instead).

◆ kzsExceptionForward

#define kzsExceptionForward (   exception)

Return from the function with the given exception or error code, if it is one.

Otherwise continue.

◆ kzsExceptionForwardAsError

#define kzsExceptionForwardAsError (   exception,
  new_error,
  logMessage 
)

If the given exception code is an error, pass it forward.

If it is an exception, substitute it with the given error. Otherwise continue.

◆ kzsErrorSubstitute

#define kzsErrorSubstitute (   error,
  new_error,
  logMessage 
)

Return from the function with the given new error code, if the given old code is also an error.

Otherwise continue.

◆ kzsExceptionSubstitute

#define kzsExceptionSubstitute (   error,
  new_exception,
  logMessage 
)

Return from the function with the given new exception code, if the given old code is also an exception.

Otherwise continue.

◆ kzsErrorIf

#define kzsErrorIf (   error)

Test if the given error is an error.

◆ kzsExceptionCatch

#define kzsExceptionCatch (   exception,
  exception_code 
)

Test if the given exception matches the specified exception code.

◆ kzsExceptionCatchAll

#define kzsExceptionCatchAll (   exception)

Test if the given exception is an actual exception and not success or error.

◆ KZS_NOT_IMPLEMENTED_YET

#define KZS_NOT_IMPLEMENTED_YET

Macro to use to indicate that some code is not yet implemented.

◆ KZS_NOT_IMPLEMENTED_YET_ERROR

#define KZS_NOT_IMPLEMENTED_YET_ERROR

Macro to use to indicate and throw error that some code is not yet implemented.

◆ KZS_NOT_IMPLEMENTED_YET_ERROR_TEXT

#define KZS_NOT_IMPLEMENTED_YET_ERROR_TEXT (   message)

Macro to use to indicate and throw error with an explanation, that some code is not yet implemented.

◆ kzsErrorLog

#define kzsErrorLog (   errorCode,
  message 
)

Logs the given error code with given message.

◆ kzsExceptionLog

#define kzsExceptionLog (   errorCode,
  message 
)

Logs exception with given error code with given message.

Typedef Documentation

◆ kzsError

typedef int kzsError

Error code type definition.

◆ kzsException

typedef int kzsException

Exception code type definition, extends error.

◆ KzsErrorCallback

typedef void(* KzsErrorCallback) (kzsError errorCode, kzString message)

Callback that is triggered in error situations.

◆ KzsExceptionCallback

typedef void(* KzsExceptionCallback) (kzsError errorCode, kzString message)

Callback that is triggered in exception situations.

Function Documentation

◆ kzsErrorThrow_private()

void kzsErrorThrow_private ( kzsError  error,
kzString  message 
)

Wrapper for kzsErrorThrow() to share more code.

◆ kzsExceptionThrow_private()

void kzsExceptionThrow_private ( kzsError  error,
kzString  message 
)

Wrapper for kzsExceptionThrow() to share more code.

◆ kzsStoreErrorMessage()

void kzsStoreErrorMessage ( kzsError  errorCode,
kzString  message 
)

Stores error message in global storage area.

◆ kzsStoreExceptionMessage()

void kzsStoreExceptionMessage ( kzString  message)

Stores exception message in per-thread data area.

◆ kzsErrorInitializeThread()

kzsError kzsErrorInitializeThread ( kzMutableString  storage)

Initializes error handling for thread.

◆ kzsErrorDeinitializeThread()

kzsError kzsErrorDeinitializeThread ( void  )

De-initializes error handling for thread.

◆ kzsErrorInitialize()

kzsError kzsErrorInitialize ( void  )

Initialize a global variable for error message storage.

◆ kzsErrorUninitialize()

kzsError kzsErrorUninitialize ( void  )

De-initialize a global variable for error message storage.

◆ kzsErrorSetErrorCallback()

void kzsErrorSetErrorCallback ( KzsErrorCallback  callback)

Sets error callback.

◆ kzsErrorSetExceptionCallback()

void kzsErrorSetExceptionCallback ( KzsExceptionCallback  callback)

Sets exception callback.

◆ kzsErrorGetLastErrorMessage()

kzString kzsErrorGetLastErrorMessage ( )

Gets last error message stored in a global buffer or empty string if there are no errors have being reported yet.

◆ kzsErrorGetLastExceptionMessage() [1/2]

kzString kzsErrorGetLastExceptionMessage ( )

Gets the last exception message for the thread or empty string if there are no exceptions have being reported yet.

◆ kzsErrorGetLastExceptionMessage() [2/2]

kzString kzsErrorGetLastExceptionMessage ( kzString  fallbackMessage)

Gets the last exception message for the thread.

Returns fallbackMessage if are no exceptions have being reported yet.

◆ kzsErrorGetLastErrorCode()

kzsError kzsErrorGetLastErrorCode ( )

Gets last error code.