Objectively
Ultra-lightweight object oriented framework for GNU C.
Loading...
Searching...
No Matches
Error Struct Reference

#include <Error.h>

Overview

Encapsulation for error conditions.

Definition at line 41 of file Error.h.

Inheritance diagram for Error:
Object

Properties

int code
 The error code.
 
Stringdomain
 The error domain.
 
Stringmessage
 The error message.
 
Object object
 The superclass.
 
- Properties inherited from Object
Classclazz
 Every instance of Object begins with a pointer to its Class.
 
unsigned int magic
 A header to allow introspection of Object types.
 

Methods

Class_Error (void)
 The Error archetype.
 
ErrorinitWithDomain (Error *self, String *domain, int code, String *message)
 Initializes an Error with the given details.
 
- Methods inherited from Object
Class_Object (void)
 The Object archetype.
 
Objectcopy (const Object *self)
 Creates a shallow copy of this Object.
 
void dealloc (Object *self)
 Frees all resources held by this Object.
 
Stringdescription (const Object *self)
 
int hash (const Object *self)
 
Objectinit (Object *self)
 Initializes this Object.
 
bool isEqual (const Object *self, const Object *other)
 Tests equality of the other Object.
 
bool isKindOfClass (const Object *self, const Class *clazz)
 Tests for Class hierarchy membership.
 

Protected Attributes

ErrorInterface * interface
 The interface.
 
- Protected Attributes inherited from Object
ObjectInterface * interface
 The interface.
 

Property Details

◆ code

int Error::code

The error code.

Definition at line 57 of file Error.h.

◆ domain

String* Error::domain

The error domain.

Definition at line 62 of file Error.h.

◆ interface

ErrorInterface* Error::interface
protected

The interface.

Definition at line 52 of file Error.h.

◆ message

String* Error::message

The error message.

Definition at line 67 of file Error.h.

◆ object

Object Error::object

The superclass.

Definition at line 46 of file Error.h.

Method Details

◆ _Error()

Class * _Error ( void  )

The Error archetype.

Returns
The Error Class.

Definition at line 166 of file Error.c.

166 {
167 static Class *clazz;
168 static Once once;
169
170 do_once(&once, {
171 clazz = _initialize(&(const ClassDef) {
172 .name = "Error",
173 .superclass = _Object(),
174 .instanceSize = sizeof(Error),
175 .interfaceOffset = offsetof(Error, interface),
176 .interfaceSize = sizeof(ErrorInterface),
178 });
179 });
180
181 return clazz;
182}
static void initialize(Class *clazz)
Definition Array.c:710
Class * _initialize(const ClassDef *def)
Initializes the given Class.
Definition Class.c:86
long Once
The Once type.
Definition Once.h:37
#define do_once(once, block)
Executes the given block at most one time.
Definition Once.h:43
ClassDefs are passed to _initialize via an archetype to initialize a Class.
Definition Class.h:41
The runtime representation of a Class.
Definition Class.h:95
Encapsulation for error conditions.
Definition Error.h:41
ErrorInterface * interface
The interface.
Definition Error.h:52
Class * clazz
Every instance of Object begins with a pointer to its Class.
Definition Object.h:55
Class * _Object(void)
The Object archetype.
Definition Object.c:136

◆ initWithDomain()

Error * initWithDomain ( Error self,
String domain,
int  code,
String message 
)

Initializes an Error with the given details.

Parameters
selfThe Error.
domainThe Error domain (required).
codeThe error code.
messageThe error message.
Returns
The initialized Error, or NULL on error.

Definition at line 128 of file Error.c.

128 {
129
130 assert(domain);
131
132 self = (Error *) super(Object, self, init);
133 if (self) {
134
135 self->domain = retain(domain);
136 self->code = code;
137
138 if (message) {
139 self->message = retain(message);
140 }
141 }
142
143 return self;
144}
ident retain(ident obj)
Atomically increment the given Object's reference count.
Definition Class.c:210
#define super(type, obj, method,...)
int code
The error code.
Definition Error.h:57
String * message
The error message.
Definition Error.h:67
String * domain
The error domain.
Definition Error.h:62
Object is the root Class of The Objectively Class hierarchy.
Definition Object.h:46
Object * init(Object *self)
Initializes this Object.
Definition Object.c:83

The documentation for this struct was generated from the following files: