File: rb_cairo_exception.c

package info (click to toggle)
ruby-cairo 1.17.13-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,532 kB
  • sloc: ruby: 11,997; ansic: 10,183; sh: 48; makefile: 4
file content (527 lines) | stat: -rw-r--r-- 19,702 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
/* -*- c-file-style: "gnu"; indent-tabs-mode: nil -*- */
/*
 * Ruby Cairo Binding
 *
 * $Author: kou $
 * $Date: 2008-08-16 12:52:16 $
 *
 * Copyright 2010-2023 Sutou Kouhei <kou@cozmixng.org>
 * Copyright 2005 Øyvind Kolås <pippin@freedesktop.org>
 * Copyright 2004-2005 MenTaLguY <mental@rydia.com>
 *
 * This file is made available under the same terms as Ruby
 *
*/

#include "rb_cairo.h"
#include "rb_cairo_private.h"

static VALUE rb_eCairo_InvalidRestoreError;
static VALUE rb_eCairo_InvalidPopGroupError;
static VALUE rb_eCairo_NoCurrentPointError;
static VALUE rb_eCairo_InvalidMatrixError;
static VALUE rb_eCairo_InvalidStatusError;
static VALUE rb_eCairo_NullPointerError;
static VALUE rb_eCairo_InvalidStringError;
static VALUE rb_eCairo_InvalidPathDataError;
static VALUE rb_eCairo_ReadError;
static VALUE rb_eCairo_WriteError;
static VALUE rb_eCairo_SurfaceFinishedError;
static VALUE rb_eCairo_SurfaceTypeMismatchError;
static VALUE rb_eCairo_PatternTypeMismatchError;
static VALUE rb_eCairo_InvalidContentError;
static VALUE rb_eCairo_InvalidFormatError;
static VALUE rb_eCairo_InvalidVisualError;
static VALUE rb_eCairo_FileNotFoundError;
static VALUE rb_eCairo_InvalidDashError;
static VALUE rb_eCairo_InvalidDscCommentError;
#if CAIRO_CHECK_VERSION(1, 3, 0)
static VALUE rb_eCairo_InvalidIndexError;
static VALUE rb_eCairo_ClipNotRepresentableError;
#endif
#if CAIRO_CHECK_VERSION(1, 5, 6)
static VALUE rb_eCairo_TempFileError;
static VALUE rb_eCairo_InvalidStrideError;
#endif
#if CAIRO_CHECK_VERSION(1, 7, 2)
static VALUE rb_eCairo_FontTypeMismatch;
static VALUE rb_eCairo_UserFontImmutable;
static VALUE rb_eCairo_UserFontError;
static VALUE rb_eCairo_NegativeCount;
static VALUE rb_eCairo_InvalidClusters;
static VALUE rb_eCairo_InvalidSlant;
static VALUE rb_eCairo_InvalidWeight;
#endif
#if CAIRO_CHECK_VERSION(1, 10, 0)
static VALUE rb_eCairo_InvalidSize;
static VALUE rb_eCairo_UserFontNotImplemented;
static VALUE rb_eCairo_DeviceTypeMismatch;
static VALUE rb_eCairo_DeviceError;
#endif
#if CAIRO_CHECK_VERSION(1, 11, 2)
static VALUE rb_eCairo_InvalidMeshConstruction;
static VALUE rb_eCairo_DeviceFinished;
#endif
#if CAIRO_CHECK_VERSION(1, 14, 0)
static VALUE rb_eCairo_JBIG2GlobalMissing;
#endif
#if CAIRO_CHECK_VERSION(1, 15, 4)
static VALUE rb_eCairo_PNGError;
static VALUE rb_eCairo_FreeTypeError;
static VALUE rb_eCairo_Win32GDIError;
static VALUE rb_eCairo_TagError;
#endif
#if CAIRO_CHECK_VERSION(1, 17, 6)
static VALUE rb_eCairo_DirectWriteError;
#endif
#if CAIRO_CHECK_VERSION(1, 17, 8)
static VALUE rb_eCairo_SVGFontError;
#endif

void
rb_cairo_check_status (cairo_status_t status)
{
  const char *string = cairo_status_to_string (status);

  switch (status)
    {
    case CAIRO_STATUS_SUCCESS:
      break;
    case CAIRO_STATUS_NO_MEMORY:
      rb_raise (rb_eNoMemError, "%s", string);
      break;
    case CAIRO_STATUS_INVALID_RESTORE:
      rb_raise (rb_eCairo_InvalidRestoreError, "%s", string);
      break;
    case CAIRO_STATUS_INVALID_POP_GROUP:
      rb_raise (rb_eCairo_InvalidPopGroupError, "%s", string);
      break;
    case CAIRO_STATUS_NO_CURRENT_POINT:
      rb_raise (rb_eCairo_NoCurrentPointError, "%s", string);
      break;
    case CAIRO_STATUS_INVALID_MATRIX:
      rb_raise (rb_eCairo_InvalidMatrixError, "%s", string);
      break;
    case CAIRO_STATUS_INVALID_STATUS:
      rb_raise (rb_eCairo_InvalidStatusError, "%s", string);
      break;
    case CAIRO_STATUS_NULL_POINTER:
      rb_raise (rb_eCairo_NullPointerError, "%s", string);
      break;
    case CAIRO_STATUS_INVALID_STRING:
      rb_raise (rb_eCairo_InvalidStringError, "%s", string);
      break;
    case CAIRO_STATUS_INVALID_PATH_DATA:
      rb_raise (rb_eCairo_InvalidPathDataError, "%s", string);
      break;
    case CAIRO_STATUS_READ_ERROR:
      rb_raise (rb_eCairo_ReadError, "%s", string);
      break;
    case CAIRO_STATUS_WRITE_ERROR:
      rb_raise (rb_eCairo_WriteError, "%s", string);
      break;
    case CAIRO_STATUS_SURFACE_FINISHED:
      rb_raise (rb_eCairo_SurfaceFinishedError, "%s", string);
      break;
    case CAIRO_STATUS_SURFACE_TYPE_MISMATCH:
      rb_raise (rb_eCairo_SurfaceTypeMismatchError, "%s", string);
      break;
    case CAIRO_STATUS_PATTERN_TYPE_MISMATCH:
      rb_raise (rb_eCairo_PatternTypeMismatchError, "%s", string);
      break;
    case CAIRO_STATUS_INVALID_CONTENT:
      rb_raise (rb_eCairo_InvalidContentError, "%s", string);
      break;
    case CAIRO_STATUS_INVALID_FORMAT:
      rb_raise (rb_eCairo_InvalidFormatError, "%s", string);
      break;
    case CAIRO_STATUS_INVALID_VISUAL:
      rb_raise (rb_eCairo_InvalidVisualError, "%s", string);
      break;
    case CAIRO_STATUS_FILE_NOT_FOUND:
      rb_raise (rb_eCairo_FileNotFoundError, "%s", string);
      break;
    case CAIRO_STATUS_INVALID_DASH:
      rb_raise (rb_eCairo_InvalidDashError, "%s", string);
      break;
    case CAIRO_STATUS_INVALID_DSC_COMMENT:
      rb_raise (rb_eCairo_InvalidDscCommentError, "%s", string);
      break;
#if CAIRO_CHECK_VERSION(1, 3, 0)
    case CAIRO_STATUS_INVALID_INDEX:
      rb_raise (rb_eCairo_InvalidIndexError, "%s", string);
      break;
    case CAIRO_STATUS_CLIP_NOT_REPRESENTABLE:
      rb_raise (rb_eCairo_ClipNotRepresentableError, "%s", string);
      break;
#endif
#if CAIRO_CHECK_VERSION(1, 5, 6)
    case CAIRO_STATUS_TEMP_FILE_ERROR:
      rb_raise (rb_eCairo_TempFileError, "%s", string);
      break;
    case CAIRO_STATUS_INVALID_STRIDE:
      rb_raise (rb_eCairo_InvalidStringError, "%s", string);
      break;
#endif
#if CAIRO_CHECK_VERSION(1, 7, 2)
    case CAIRO_STATUS_FONT_TYPE_MISMATCH:
      rb_raise (rb_eCairo_FontTypeMismatch, "%s", string);
      break;
    case CAIRO_STATUS_USER_FONT_IMMUTABLE:
      rb_raise (rb_eCairo_UserFontImmutable, "%s", string);
      break;
    case CAIRO_STATUS_USER_FONT_ERROR:
      rb_raise (rb_eCairo_UserFontError, "%s", string);
      break;
    case CAIRO_STATUS_NEGATIVE_COUNT:
      rb_raise (rb_eCairo_NegativeCount, "%s", string);
      break;
    case CAIRO_STATUS_INVALID_CLUSTERS:
      rb_raise (rb_eCairo_InvalidClusters, "%s", string);
      break;
    case CAIRO_STATUS_INVALID_SLANT:
      rb_raise (rb_eCairo_InvalidSlant, "%s", string);
      break;
    case CAIRO_STATUS_INVALID_WEIGHT:
      rb_raise (rb_eCairo_InvalidWeight, "%s", string);
      break;
#endif
#if CAIRO_CHECK_VERSION(1, 10, 0)
    case CAIRO_STATUS_INVALID_SIZE:
      rb_raise (rb_eCairo_InvalidSize, "%s", string);
      break;
    case CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED:
      rb_raise (rb_eCairo_UserFontNotImplemented, "%s", string);
      break;
    case CAIRO_STATUS_DEVICE_TYPE_MISMATCH:
      rb_raise (rb_eCairo_DeviceTypeMismatch, "%s", string);
      break;
    case CAIRO_STATUS_DEVICE_ERROR:
      rb_raise (rb_eCairo_DeviceError, "%s", string);
      break;
#endif
#if CAIRO_CHECK_VERSION(1, 11, 2)
    case CAIRO_STATUS_INVALID_MESH_CONSTRUCTION:
      rb_raise (rb_eCairo_InvalidMeshConstruction, "%s", string);
      break;
    case CAIRO_STATUS_DEVICE_FINISHED:
      rb_raise (rb_eCairo_DeviceFinished, "%s", string);
      break;
#endif
#if CAIRO_CHECK_VERSION(1, 14, 0)
    case CAIRO_STATUS_JBIG2_GLOBAL_MISSING:
      rb_raise (rb_eCairo_JBIG2GlobalMissing, "%s", string);
      break;
#endif
#if CAIRO_CHECK_VERSION(1, 15, 4)
    case CAIRO_STATUS_PNG_ERROR:
      rb_raise (rb_eCairo_PNGError, "%s", string);
      break;
    case CAIRO_STATUS_FREETYPE_ERROR:
      rb_raise (rb_eCairo_FreeTypeError, "%s", string);
      break;
    case CAIRO_STATUS_WIN32_GDI_ERROR:
      rb_raise (rb_eCairo_Win32GDIError, "%s", string);
      break;
    case CAIRO_STATUS_TAG_ERROR:
      rb_raise (rb_eCairo_TagError, "%s", string);
      break;
#endif
#if CAIRO_CHECK_VERSION(1, 17, 6)
    case CAIRO_STATUS_DWRITE_ERROR:
      rb_raise (rb_eCairo_DirectWriteError, "%s", string);
      break;
#endif
#if CAIRO_CHECK_VERSION(1, 17, 8)
    case CAIRO_STATUS_SVG_FONT_ERROR:
      rb_raise (rb_eCairo_SVGFontError, "%s", string);
      break;
#endif
#if CAIRO_CHECK_VERSION(1, 10, 0)
    case CAIRO_STATUS_LAST_STATUS:
#else
    default:
#endif
      rb_raise (rb_eArgError, "bug: %s: %d", string, status);
      break;
    }
}

cairo_status_t
rb_cairo__exception_to_status (VALUE exception)
{
  if (NIL_P (exception))
    return CAIRO_STATUS_SUCCESS;
  else if (rb_cairo__is_kind_of (exception, rb_eNoMemError))
    return CAIRO_STATUS_NO_MEMORY;
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_InvalidRestoreError))
    return CAIRO_STATUS_INVALID_RESTORE;
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_InvalidPopGroupError))
    return CAIRO_STATUS_INVALID_POP_GROUP;
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_NoCurrentPointError))
    return CAIRO_STATUS_NO_CURRENT_POINT;
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_InvalidMatrixError))
    return CAIRO_STATUS_INVALID_MATRIX;
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_InvalidStatusError))
    return CAIRO_STATUS_INVALID_STATUS;
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_NullPointerError))
    return CAIRO_STATUS_NULL_POINTER;
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_InvalidStringError))
    return CAIRO_STATUS_INVALID_STRING;
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_InvalidPathDataError))
    return CAIRO_STATUS_INVALID_PATH_DATA;
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_ReadError))
    return CAIRO_STATUS_READ_ERROR;
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_WriteError))
    return CAIRO_STATUS_WRITE_ERROR;
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_SurfaceFinishedError))
    return CAIRO_STATUS_SURFACE_FINISHED;
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_SurfaceTypeMismatchError))
    return CAIRO_STATUS_SURFACE_TYPE_MISMATCH;
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_PatternTypeMismatchError))
    return CAIRO_STATUS_PATTERN_TYPE_MISMATCH;
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_InvalidContentError))
    return CAIRO_STATUS_INVALID_CONTENT;
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_InvalidFormatError))
    return CAIRO_STATUS_INVALID_FORMAT;
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_InvalidVisualError))
    return CAIRO_STATUS_INVALID_VISUAL;
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_FileNotFoundError))
    return CAIRO_STATUS_FILE_NOT_FOUND;
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_InvalidDashError))
    return CAIRO_STATUS_INVALID_DASH;
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_InvalidDscCommentError))
    return CAIRO_STATUS_INVALID_DSC_COMMENT;
#if CAIRO_CHECK_VERSION(1, 3, 0)
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_InvalidIndexError))
    return CAIRO_STATUS_INVALID_INDEX;
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_ClipNotRepresentableError))
    return CAIRO_STATUS_CLIP_NOT_REPRESENTABLE;
#endif
#if CAIRO_CHECK_VERSION(1, 5, 6)
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_TempFileError))
    return CAIRO_STATUS_TEMP_FILE_ERROR;
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_InvalidStringError))
    return CAIRO_STATUS_INVALID_STRIDE;
#endif
#if CAIRO_CHECK_VERSION(1, 7, 2)
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_FontTypeMismatch))
    return CAIRO_STATUS_FONT_TYPE_MISMATCH;
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_UserFontImmutable))
    return CAIRO_STATUS_USER_FONT_IMMUTABLE;
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_UserFontError))
    return CAIRO_STATUS_USER_FONT_ERROR;
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_NegativeCount))
    return CAIRO_STATUS_NEGATIVE_COUNT;
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_InvalidClusters))
    return CAIRO_STATUS_INVALID_CLUSTERS;
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_InvalidSlant))
    return CAIRO_STATUS_INVALID_SLANT;
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_InvalidWeight))
    return CAIRO_STATUS_INVALID_WEIGHT;
#endif
#if CAIRO_CHECK_VERSION(1, 10, 0)
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_InvalidSize))
    return CAIRO_STATUS_INVALID_SIZE;
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_UserFontNotImplemented))
    return CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED;
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_DeviceTypeMismatch))
    return CAIRO_STATUS_DEVICE_TYPE_MISMATCH;
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_DeviceError))
    return CAIRO_STATUS_DEVICE_ERROR;
#endif
#if CAIRO_CHECK_VERSION(1, 14, 0)
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_JBIG2GlobalMissing))
    return CAIRO_STATUS_JBIG2_GLOBAL_MISSING;
#endif
#if CAIRO_CHECK_VERSION(1, 15, 4)
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_PNGError))
    return CAIRO_STATUS_PNG_ERROR;
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_FreeTypeError))
    return CAIRO_STATUS_FREETYPE_ERROR;
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_Win32GDIError))
    return CAIRO_STATUS_WIN32_GDI_ERROR;
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_TagError))
    return CAIRO_STATUS_TAG_ERROR;
#endif
#if CAIRO_CHECK_VERSION(1, 17, 6)
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_DirectWriteError))
    return CAIRO_STATUS_DWRITE_ERROR;
#endif
#if CAIRO_CHECK_VERSION(1, 17, 8)
  else if (rb_cairo__is_kind_of (exception, rb_eCairo_SVGFontError))
    return CAIRO_STATUS_SVG_FONT_ERROR;
#endif

  return -1;
}

void
Init_cairo_exception (void)
{
  VALUE rb_eCairo_Error;
  rb_eCairo_Error =
    rb_define_class_under (rb_mCairo, "Error", rb_eStandardError);
  rb_eCairo_InvalidRestoreError =
    rb_define_class_under (rb_mCairo, "InvalidRestoreError",
                           rb_eCairo_Error);
  rb_eCairo_InvalidPopGroupError =
    rb_define_class_under (rb_mCairo, "InvalidPopGroupError",
                           rb_eCairo_Error);
  rb_eCairo_NoCurrentPointError =
    rb_define_class_under (rb_mCairo, "NoCurrentPointError",
                           rb_eCairo_Error);
  rb_eCairo_InvalidMatrixError =
    rb_define_class_under (rb_mCairo, "InvalidMatrixError",
                           rb_eArgError);
  rb_eCairo_InvalidStatusError =
    rb_define_class_under (rb_mCairo, "InvalidStatusError",
                           rb_eArgError);
  rb_eCairo_NullPointerError =
    rb_define_class_under (rb_mCairo, "NullPointerError",
                           rb_eTypeError);
  rb_eCairo_InvalidStringError =
    rb_define_class_under (rb_mCairo, "InvalidStringError",
                           rb_eArgError);
  rb_eCairo_InvalidPathDataError =
    rb_define_class_under (rb_mCairo, "InvalidPathDataError",
                           rb_eArgError);
  rb_eCairo_ReadError =
    rb_define_class_under (rb_mCairo, "ReadError",
                           rb_eIOError);
  rb_eCairo_WriteError =
    rb_define_class_under (rb_mCairo, "WriteError",
                           rb_eIOError);
  rb_eCairo_SurfaceFinishedError =
    rb_define_class_under (rb_mCairo, "SurfaceFinishedError",
                           rb_eCairo_Error);
  rb_eCairo_SurfaceTypeMismatchError =
    rb_define_class_under (rb_mCairo, "SurfaceTypeMismatchError",
                           rb_eTypeError);
  rb_eCairo_PatternTypeMismatchError =
    rb_define_class_under (rb_mCairo, "PatternTypeMismatchError",
                           rb_eTypeError);
  rb_eCairo_InvalidContentError =
    rb_define_class_under (rb_mCairo, "InvalidContentError",
                           rb_eArgError);
  rb_eCairo_InvalidFormatError =
    rb_define_class_under (rb_mCairo, "InvalidFormatError",
                           rb_eArgError);
  rb_eCairo_InvalidVisualError =
    rb_define_class_under (rb_mCairo, "InvalidVisualError",
                           rb_eArgError);
  rb_eCairo_FileNotFoundError =
    rb_define_class_under (rb_mCairo, "FileNotFound",
                           rb_eCairo_Error);
  rb_eCairo_InvalidDashError =
    rb_define_class_under (rb_mCairo, "InvalidDashError",
                           rb_eArgError);
  rb_eCairo_InvalidDscCommentError =
    rb_define_class_under (rb_mCairo, "InvalidDscCommentError",
                           rb_eArgError);
#if CAIRO_CHECK_VERSION(1, 3, 0)
  rb_eCairo_InvalidIndexError =
    rb_define_class_under (rb_mCairo, "InvalidIndexError",
                           rb_eArgError);
  rb_eCairo_ClipNotRepresentableError =
    rb_define_class_under (rb_mCairo, "ClipNotRepresentableError",
                           rb_eCairo_Error);
#endif

#if CAIRO_CHECK_VERSION(1, 5, 6)
  rb_eCairo_TempFileError =
    rb_define_class_under (rb_mCairo, "TempFileError",
                           rb_eCairo_Error);

  rb_eCairo_InvalidStrideError =
    rb_define_class_under (rb_mCairo, "InvalidStrideError",
                           rb_eArgError);
#endif

#if CAIRO_CHECK_VERSION(1, 7, 2)
  rb_eCairo_FontTypeMismatch =
    rb_define_class_under (rb_mCairo, "FontTypeMismatch",
                           rb_eCairo_Error);

  rb_eCairo_UserFontImmutable =
    rb_define_class_under (rb_mCairo, "UserFontImmutable",
                           rb_eCairo_Error);

  rb_eCairo_UserFontError =
    rb_define_class_under (rb_mCairo, "UserFontError",
                           rb_eCairo_Error);

  rb_eCairo_NegativeCount =
    rb_define_class_under (rb_mCairo, "NegativeCount",
                           rb_eCairo_Error);

  rb_eCairo_InvalidClusters =
    rb_define_class_under (rb_mCairo, "InvalidClusters",
                           rb_eArgError);

  rb_eCairo_InvalidSlant =
    rb_define_class_under (rb_mCairo, "InvalidSlant",
                           rb_eCairo_Error);

  rb_eCairo_InvalidWeight =
    rb_define_class_under (rb_mCairo, "InvalidWeight",
                           rb_eArgError);
#endif

#if CAIRO_CHECK_VERSION(1, 10, 0)
  rb_eCairo_InvalidSize =
    rb_define_class_under (rb_mCairo, "InvalidSize",
                           rb_eArgError);

  rb_eCairo_UserFontNotImplemented =
    rb_define_class_under (rb_mCairo, "UserFontNotImplemented",
                           rb_eCairo_Error);

  rb_eCairo_DeviceTypeMismatch =
    rb_define_class_under (rb_mCairo, "DeviceTypeMismatch",
                           rb_eArgError);

  rb_eCairo_DeviceError =
    rb_define_class_under (rb_mCairo, "DeviceError",
                           rb_eCairo_Error);
#endif
#if CAIRO_CHECK_VERSION(1, 11, 2)
  rb_eCairo_InvalidMeshConstruction =
    rb_define_class_under (rb_mCairo, "InvalidMeshConstruction",
                           rb_eArgError);
  rb_eCairo_DeviceFinished =
    rb_define_class_under (rb_mCairo, "DeviceFinished",
                           rb_eCairo_Error);
#endif
#if CAIRO_CHECK_VERSION(1, 14, 0)
  rb_eCairo_JBIG2GlobalMissing =
    rb_define_class_under (rb_mCairo, "JBIG2GlobalMissing",
                           rb_eCairo_Error);
#endif
#if CAIRO_CHECK_VERSION(1, 15, 4)
  rb_eCairo_PNGError =
    rb_define_class_under (rb_mCairo, "PNGError",
                           rb_eCairo_Error);
  rb_eCairo_FreeTypeError =
    rb_define_class_under (rb_mCairo, "FreeTypeError",
                           rb_eCairo_Error);
  rb_eCairo_Win32GDIError =
    rb_define_class_under (rb_mCairo, "Win32GDIError",
                           rb_eCairo_Error);
  rb_eCairo_TagError =
    rb_define_class_under (rb_mCairo, "TagError",
                           rb_eCairo_Error);
#endif

#if CAIRO_CHECK_VERSION(1, 17, 6)
  rb_eCairo_DirectWriteError =
    rb_define_class_under (rb_mCairo, "DirectWriteError",
                           rb_eCairo_Error);
#endif

#if CAIRO_CHECK_VERSION(1, 17, 8)
  rb_eCairo_SVGFontError =
    rb_define_class_under (rb_mCairo, "SVGFontError",
                           rb_eCairo_Error);
#endif
}