Loading...
Searching...
No Matches
exception.in.h
Go to the documentation of this file.
/*
libparted - a library for manipulating disk partitions
Copyright (C) 1999-2000, 2007, 2009-2014, 2019-2023, 2026 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PED_EXCEPTION_H_INCLUDED
#define PED_EXCEPTION_H_INCLUDED
typedef struct _PedException PedException;
enum _PedExceptionType {
PED_EXCEPTION_INFORMATION=1,
PED_EXCEPTION_WARNING=2,
PED_EXCEPTION_ERROR=3,
PED_EXCEPTION_FATAL=4,
PED_EXCEPTION_BUG=5,
PED_EXCEPTION_NO_FEATURE=6,
};
typedef enum _PedExceptionType PedExceptionType;
enum _PedExceptionOption {
/* individual options */
PED_EXCEPTION_UNHANDLED=0,
PED_EXCEPTION_FIX=1,
PED_EXCEPTION_YES=2,
PED_EXCEPTION_NO=4,
PED_EXCEPTION_OK=8,
PED_EXCEPTION_RETRY=16,
PED_EXCEPTION_IGNORE=32,
PED_EXCEPTION_CANCEL=64,
/* combinations of individual options */
PED_EXCEPTION_OK_CANCEL = PED_EXCEPTION_OK + PED_EXCEPTION_CANCEL,
PED_EXCEPTION_YES_NO = PED_EXCEPTION_YES + PED_EXCEPTION_NO,
PED_EXCEPTION_YES_NO_CANCEL =
PED_EXCEPTION_YES_NO + PED_EXCEPTION_CANCEL,
PED_EXCEPTION_IGNORE_CANCEL =
PED_EXCEPTION_IGNORE + PED_EXCEPTION_CANCEL,
PED_EXCEPTION_RETRY_CANCEL = PED_EXCEPTION_RETRY + PED_EXCEPTION_CANCEL,
PED_EXCEPTION_RETRY_IGNORE_CANCEL =
PED_EXCEPTION_RETRY + PED_EXCEPTION_IGNORE_CANCEL,
};
#define PED_EXCEPTION_OPTION_FIRST PED_EXCEPTION_FIX
#define PED_EXCEPTION_OPTION_LAST PED_EXCEPTION_CANCEL /* last individual option */
typedef enum _PedExceptionOption PedExceptionOption;
struct _PedException {
char* message;
PedExceptionType type;
PedExceptionOption options;
};
typedef PedExceptionOption (PedExceptionHandler) (PedException* ex);
extern int ped_exception; /* set to true if there's an exception */
extern char* ped_exception_get_type_string (PedExceptionType ex_type)
_GL_ATTRIBUTE_CONST;
extern char* ped_exception_get_option_string (PedExceptionOption ex_opt)
_GL_ATTRIBUTE_PURE;
extern void ped_exception_set_handler (PedExceptionHandler* handler);
extern PedExceptionHandler *ped_exception_get_handler(void)
_GL_ATTRIBUTE_PURE;
extern PedExceptionOption ped_exception_default_handler (PedException* ex);
extern PedExceptionOption ped_exception_throw (PedExceptionType ex_type,
PedExceptionOption ex_opt,
const char* message,
...);
/* rethrows an exception - i.e. calls the exception handler, (or returns a
code to return to pass up higher) */
extern PedExceptionOption ped_exception_rethrow ();
/* frees an exception, indicating that the exception has been handled.
Calling an exception handler counts. */
extern void ped_exception_catch ();
/* indicate that exceptions should not go to the exception handler, but passed
up to the calling function(s) */
extern void ped_exception_fetch_all ();
/* indicate that exceptions should invoke the exception handler */
extern void ped_exception_leave_all ();
#endif /* PED_EXCEPTION_H_INCLUDED */
type
uint8_t type
Definition dos.c:2
ped_exception_set_handler
void ped_exception_set_handler(PedExceptionHandler *handler)
Set the exception handler.
Definition exception.c:166
ped_exception_throw
PedExceptionOption ped_exception_throw(PedExceptionType ex_type, PedExceptionOption ex_opt, const char *message,...)
Throw an exception.
Definition exception.c:230
ped_exception_rethrow
PedExceptionOption ped_exception_rethrow()
Rethrow an unhandled exception.
Definition exception.c:280
ped_exception_get_type_string
char * ped_exception_get_type_string(PedExceptionType ex_type)
Return a string describing an exception type.
Definition exception.c:101
ped_exception_default_handler
PedExceptionOption ped_exception_default_handler(PedException *ex)
_PedExceptionType
_PedExceptionType
Exception type.
Definition exception.h:35
ped_exception_get_option_string
char * ped_exception_get_option_string(PedExceptionOption ex_opt)
Return a string describing an exception option.
Definition exception.c:124
ped_exception_get_handler
PedExceptionHandler * ped_exception_get_handler(void)
Get the current exception handler.
Definition exception.c:178
ped_exception_leave_all
void ped_exception_leave_all()
Indicates that the calling function does not want to accept any responsibility for exceptions any mor...
Definition exception.c:307
PedExceptionHandler
PedExceptionOption PedExceptionHandler(PedException *ex)
Definition exception.h:88
_PedExceptionOption
_PedExceptionOption
Option for resolving the exception.
Definition exception.h:48
ped_exception_fetch_all
void ped_exception_fetch_all()
Indicates that exceptions should not go to the exception handler, but passed up to the calling functi...
Definition exception.c:291
PedExceptionType
enum _PedExceptionType PedExceptionType
Definition exception.h:43
ped_exception
int ped_exception
Definition exception.c:70
PedExceptionOption
enum _PedExceptionOption PedExceptionOption
Definition exception.h:74
PedException
struct _PedException PedException
Definition exception.h:30
ped_exception_catch
void ped_exception_catch()
Assert that the current exception has been resolved.
Definition exception.c:189
PED_EXCEPTION_BUG
@ PED_EXCEPTION_BUG
Definition exception.h:40
PED_EXCEPTION_INFORMATION
@ PED_EXCEPTION_INFORMATION
Definition exception.h:36
PED_EXCEPTION_WARNING
@ PED_EXCEPTION_WARNING
Definition exception.h:37
PED_EXCEPTION_NO_FEATURE
@ PED_EXCEPTION_NO_FEATURE
Definition exception.h:41
PED_EXCEPTION_FATAL
@ PED_EXCEPTION_FATAL
Definition exception.h:39
PED_EXCEPTION_ERROR
@ PED_EXCEPTION_ERROR
Definition exception.h:38
PED_EXCEPTION_RETRY
@ PED_EXCEPTION_RETRY
Definition exception.h:55
PED_EXCEPTION_RETRY_CANCEL
@ PED_EXCEPTION_RETRY_CANCEL
Definition exception.h:66
PED_EXCEPTION_IGNORE_CANCEL
@ PED_EXCEPTION_IGNORE_CANCEL
Definition exception.h:64
PED_EXCEPTION_CANCEL
@ PED_EXCEPTION_CANCEL
Definition exception.h:57
PED_EXCEPTION_YES_NO_CANCEL
@ PED_EXCEPTION_YES_NO_CANCEL
Definition exception.h:62
PED_EXCEPTION_FIX
@ PED_EXCEPTION_FIX
Definition exception.h:51
PED_EXCEPTION_NO
@ PED_EXCEPTION_NO
Definition exception.h:53
PED_EXCEPTION_OK_CANCEL
@ PED_EXCEPTION_OK_CANCEL
Definition exception.h:60
PED_EXCEPTION_RETRY_IGNORE_CANCEL
@ PED_EXCEPTION_RETRY_IGNORE_CANCEL
Definition exception.h:67
PED_EXCEPTION_IGNORE
@ PED_EXCEPTION_IGNORE
Definition exception.h:56
PED_EXCEPTION_YES_NO
@ PED_EXCEPTION_YES_NO
Definition exception.h:61
PED_EXCEPTION_YES
@ PED_EXCEPTION_YES
Definition exception.h:52
PED_EXCEPTION_OK
@ PED_EXCEPTION_OK
Definition exception.h:54
PED_EXCEPTION_UNHANDLED
@ PED_EXCEPTION_UNHANDLED
Definition exception.h:50
_PedException
Structure with information about exception.
Definition exception.h:79
_PedException::options
PedExceptionOption options
ORed list of options that the exception handler can return (the ways an exception can be resolved).
Definition exception.h:82
_PedException::message
char * message
text describing what the event was
Definition exception.h:80