Exception Handling

HPy HPyErr_SetFromErrnoWithFilename(HPyContext *ctx, HPy h_type, const char *filename_fsencoded)
[source]

Similar to HPyErr_SetFromErrnoWithFilenameObjects() but takes one filename (a C string) that will be decoded using HPyUnicode_DecodeFSDefault().

Parameters
  • ctx – The execution context.

  • h_type – The exception type to raise.

  • filename_fsencoded – a filename; may be NULL

Returns

always returns HPy_NULL

HPy HPyErr_SetFromErrnoWithFilenameObjects(HPyContext *ctx, HPy h_type, HPy filename1, HPy filename2)
[source]

A convenience function to raise an exception when a C library function has returned an error and set the C variable errno. It constructs an instance of the provided exception type h_type by calling h_type(errno, strerror(errno), filename1, 0, filename2). The exception instance is then raised.

Parameters
  • ctx – The execution context.

  • h_type – The exception type to raise.

  • filename1 – A filename; may be HPy_NULL. In the case of h_type is the OSError exception, this is used to define the filename attribute of the exception instance.

  • filename2 – another filename argument; may be HPy_NULL

Returns

always returns HPy_NULL

void HPy_FatalError(HPyContext *ctx, const char *message)
[source]
HPy HPyErr_SetString(HPyContext *ctx, HPy h_type, const char *utf8_message)
[source]
HPy HPyErr_SetObject(HPyContext *ctx, HPy h_type, HPy h_value)
[source]
int HPyErr_Occurred(HPyContext *ctx)
[source]
int HPyErr_ExceptionMatches(HPyContext *ctx, HPy exc)
[source]
HPy HPyErr_NoMemory(HPyContext *ctx)
[source]
void HPyErr_Clear(HPyContext *ctx)
[source]
HPy HPyErr_NewException(HPyContext *ctx, const char *utf8_name, HPy base, HPy dict)
[source]
HPy HPyErr_NewExceptionWithDoc(HPyContext *ctx, const char *utf8_name, const char *utf8_doc, HPy base, HPy dict)
[source]
int HPyErr_WarnEx(HPyContext *ctx, HPy category, const char *utf8_message, HPy_ssize_t stack_level)
[source]
void HPyErr_WriteUnraisable(HPyContext *ctx, HPy obj)
[source]