package ru.dbotthepony.kstarbound.client.freetype

sealed class FreeTypeException(message: String, cause: Throwable?) : RuntimeException(message, cause) {
	abstract val code: Int
}

/* generic errors */

class CannotOpenResourceException(message: String = "cannot open resource", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x01
}

class UnknownFileFormatException(message: String = "unknown file format", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x02
}

class InvalidFileFormatException(message: String = "broken file", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x03
}

class InvalidVersionException(message: String = "invalid FreeType version", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x04
}

class LowerModuleVersionException(message: String = "module version is too low", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x05
}

class InvalidArgumentException(message: String = "invalid argument", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x06
}

class UnimplementedFeatureException(message: String = "unimplemented feature", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x07
}

class InvalidTableException(message: String = "broken table", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x08
}

class InvalidOffsetException(message: String = "broken offset within table", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x09
}

class ArrayTooLargeException(message: String = "array allocation size too large", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x0A
}

class MissingModuleException(message: String = "missing module", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x0B
}

class MissingPropertyException(message: String = "missing property", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x0C
}


/* glyph/character errors */

class InvalidGlyphIndexException(message: String = "invalid glyph index", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x10
}

class InvalidCharacterCodeException(message: String = "invalid character code", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x11
}

class InvalidGlyphFormatException(message: String = "unsupported glyph image format", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x12
}

class CannotRenderGlyphException(message: String = "cannot render this glyph format", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x13
}

class InvalidOutlineException(message: String = "invalid outline", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x14
}

class InvalidCompositeException(message: String = "invalid composite glyph", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x15
}

class TooManyHintsException(message: String = "too many hints", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x16
}

class InvalidPixelSizeException(message: String = "invalid pixel size", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x17
}


/* handle errors */

class InvalidHandleException(message: String = "invalid object handle", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x20
}

class InvalidLibraryHandleException(message: String = "invalid library handle", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x21
}

class InvalidDriverHandleException(message: String = "invalid module handle", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x22
}

class InvalidFaceHandleException(message: String = "invalid face handle", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x23
}

class InvalidSizeHandleException(message: String = "invalid size handle", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x24
}

class InvalidSlotHandleException(message: String = "invalid glyph slot handle", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x25
}

class InvalidCharMapHandleException(message: String = "invalid charmap handle", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x26
}

class InvalidCacheHandleException(message: String = "invalid cache manager handle", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x27
}

class InvalidStreamHandleException(message: String = "invalid stream handle", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x28
}


/* driver errors */

class TooManyDriversException(message: String = "too many modules", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x30
}

class TooManyExtensionsException(message: String = "too many extensions", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x31
}


/* memory errors */

class OutOfMemoryException(message: String = "out of memory", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x40
}

class UnlistedObjectException(message: String = "unlisted object", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x41
}


/* stream errors */

class CannotOpenStreamException(message: String = "cannot open stream", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x51
}

class InvalidStreamSeekException(message: String = "invalid stream seek", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x52
}

class InvalidStreamSkipException(message: String = "invalid stream skip", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x53
}

class InvalidStreamReadException(message: String = "invalid stream read", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x54
}

class InvalidStreamOperationException(message: String = "invalid stream operation", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x55
}

class InvalidFrameOperationException(message: String = "invalid frame operation", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x56
}

class NestedFrameAccessException(message: String = "nested frame access", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x57
}

class InvalidFrameReadException(message: String = "invalid frame read", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x58
}


/* raster errors */

class RasterUninitializedException(message: String = "raster uninitialized", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x60
}

class RasterCorruptedException(message: String = "raster corrupted", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x61
}

class RasterOverflowException(message: String = "raster overflow", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x62
}

class RasterNegativeHeightException(message: String = "negative height while rastering", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x63
}


/* cache errors */

class TooManyCachesException(message: String = "too many registered caches", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x70
}


/* TrueType and SFNT errors */

class InvalidOpcodeException(message: String = "invalid opcode", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x80
}

class TooFewArgumentsException(message: String = "too few arguments", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x81
}

class StackOverflowException(message: String = "stack overflow", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x82
}

class CodeOverflowException(message: String = "code overflow", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x83
}

class BadArgumentException(message: String = "bad argument", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x84
}

class DivideByZeroException(message: String = "division by zero", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x85
}

class InvalidReferenceException(message: String = "invalid reference", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x86
}

class DebugOpCodeException(message: String = "found debug opcode", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x87
}

class ENDFInExecStreamException(message: String = "found ENDF opcode in execution stream", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x88
}

class NestedDEFSException(message: String = "nested DEFS", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x89
}

class InvalidCodeRangeException(message: String = "invalid code range", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x8A
}

class ExecutionTooLongException(message: String = "execution context too long", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x8B
}

class TooManyFunctionDefsException(message: String = "too many function definitions", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x8C
}

class TooManyInstructionDefsException(message: String = "too many instruction definitions", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x8D
}

class TableMissingException(message: String = "SFNT font table missing", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x8E
}

class HorizHeaderMissingException(message: String = "horizontal header (hhea) table missing", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x8F
}

class LocationsMissingException(message: String = "locations (loca) table missing", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x90
}

class NameTableMissingException(message: String = "name table missing", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x91
}

class CMapTableMissingException(message: String = "character map (cmap) table missing", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x92
}

class HmtxTableMissingException(message: String = "horizontal metrics (hmtx) table missing", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x93
}

class PostTableMissingException(message: String = "PostScript (post) table missing", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x94
}

class InvalidHorizMetricsException(message: String = "invalid horizontal metrics", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x95
}

class InvalidCharMapFormatException(message: String = "invalid character map (cmap) format", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x96
}

class InvalidPPemException(message: String = "invalid ppem value", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x97
}

class InvalidVertMetricsException(message: String = "invalid vertical metrics", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x98
}

class CouldNotFindContextException(message: String = "could not find context", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x99
}

class InvalidPostTableFormatException(message: String = "invalid PostScript (post) table format", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x9A
}

class InvalidPostTableException(message: String = "invalid PostScript (post) table", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x9B
}

class DEFInGlyfBytecodeException(message: String = "found FDEF or IDEF opcode in glyf bytecode", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x9C
}

class MissingBitmapException(message: String = "missing bitmap in strike", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0x9D
}


/* CFF, CID, and Type 1 errors */

class SyntaxErrorException(message: String = "opcode syntax error", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0xA0
}

class StackUnderflowException(message: String = "argument stack underflow", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0xA1
}

class IgnoreException(message: String = "ignore", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0xA2
}

class NoUnicodeGlyphNameException(message: String = "no Unicode glyph name found", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0xA3
}

class GlyphTooBigException(message: String = "glyph too big for hinting", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0xA4
}


/* BDF errors */

class MissingStartfontFieldException(message: String = "`STARTFONT' field missing", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0xB0
}

class MissingFontFieldException(message: String = "`FONT' field missing", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0xB1
}

class MissingSizeFieldException(message: String = "`SIZE' field missing", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0xB2
}

class MissingFontboundingboxFieldException(message: String = "`FONTBOUNDINGBOX' field missing", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0xB3
}

class MissingCharsFieldException(message: String = "`CHARS' field missing", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0xB4
}

class MissingStartcharFieldException(message: String = "`STARTCHAR' field missing", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0xB5
}

class MissingEncodingFieldException(message: String = "`ENCODING' field missing", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0xB6
}

class MissingBbxFieldException(message: String = "`BBX' field missing", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0xB7
}

class BbxTooBigException(message: String = "`BBX' too big", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0xB8
}

class CorruptedFontHeaderException(message: String = "Font header corrupted or missing fields", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0xB9
}

class CorruptedFontGlyphsException(message: String = "Font glyphs corrupted or missing fields", cause: Throwable? = null) : FreeTypeException(message, cause) {
	override val code = 0xBA
}

internal fun throwFreeTypeError(code: Int, message: String, cause: Throwable? = null) {
	when (code) {
		/* generic errors */

		0x01 -> throw CannotOpenResourceException(message, cause)
		0x02 -> throw UnknownFileFormatException(message, cause)
		0x03 -> throw InvalidFileFormatException(message, cause)
		0x04 -> throw InvalidVersionException(message, cause)
		0x05 -> throw LowerModuleVersionException(message, cause)
		0x06 -> throw InvalidArgumentException(message, cause)
		0x07 -> throw UnimplementedFeatureException(message, cause)
		0x08 -> throw InvalidTableException(message, cause)
		0x09 -> throw InvalidOffsetException(message, cause)
		0x0A -> throw ArrayTooLargeException(message, cause)
		0x0B -> throw MissingModuleException(message, cause)
		0x0C -> throw MissingPropertyException(message, cause)

		/* glyph/character errors */

		0x10 -> throw InvalidGlyphIndexException(message, cause)
		0x11 -> throw InvalidCharacterCodeException(message, cause)
		0x12 -> throw InvalidGlyphFormatException(message, cause)
		0x13 -> throw CannotRenderGlyphException(message, cause)
		0x14 -> throw InvalidOutlineException(message, cause)
		0x15 -> throw InvalidCompositeException(message, cause)
		0x16 -> throw TooManyHintsException(message, cause)
		0x17 -> throw InvalidPixelSizeException(message, cause)

		/* handle errors */

		0x20 -> throw InvalidHandleException(message, cause)
		0x21 -> throw InvalidLibraryHandleException(message, cause)
		0x22 -> throw InvalidDriverHandleException(message, cause)
		0x23 -> throw InvalidFaceHandleException(message, cause)
		0x24 -> throw InvalidSizeHandleException(message, cause)
		0x25 -> throw InvalidSlotHandleException(message, cause)
		0x26 -> throw InvalidCharMapHandleException(message, cause)
		0x27 -> throw InvalidCacheHandleException(message, cause)
		0x28 -> throw InvalidStreamHandleException(message, cause)

		/* driver errors */

		0x30 -> throw TooManyDriversException(message, cause)
		0x31 -> throw TooManyExtensionsException(message, cause)

		/* memory errors */

		0x40 -> throw OutOfMemoryException(message, cause)
		0x41 -> throw UnlistedObjectException(message, cause)

		/* stream errors */

		0x51 -> throw CannotOpenStreamException(message, cause)
		0x52 -> throw InvalidStreamSeekException(message, cause)
		0x53 -> throw InvalidStreamSkipException(message, cause)
		0x54 -> throw InvalidStreamReadException(message, cause)
		0x55 -> throw InvalidStreamOperationException(message, cause)
		0x56 -> throw InvalidFrameOperationException(message, cause)
		0x57 -> throw NestedFrameAccessException(message, cause)
		0x58 -> throw InvalidFrameReadException(message, cause)

		/* raster errors */

		0x60 -> throw RasterUninitializedException(message, cause)
		0x61 -> throw RasterCorruptedException(message, cause)
		0x62 -> throw RasterOverflowException(message, cause)
		0x63 -> throw RasterNegativeHeightException(message, cause)

		/* cache errors */

		0x70 -> throw TooManyCachesException(message, cause)

		/* TrueType and SFNT errors */

		0x80 -> throw InvalidOpcodeException(message, cause)
		0x81 -> throw TooFewArgumentsException(message, cause)
		0x82 -> throw StackOverflowException(message, cause)
		0x83 -> throw CodeOverflowException(message, cause)
		0x84 -> throw BadArgumentException(message, cause)
		0x85 -> throw DivideByZeroException(message, cause)
		0x86 -> throw InvalidReferenceException(message, cause)
		0x87 -> throw DebugOpCodeException(message, cause)
		0x88 -> throw ENDFInExecStreamException(message, cause)
		0x89 -> throw NestedDEFSException(message, cause)
		0x8A -> throw InvalidCodeRangeException(message, cause)
		0x8B -> throw ExecutionTooLongException(message, cause)
		0x8C -> throw TooManyFunctionDefsException(message, cause)
		0x8D -> throw TooManyInstructionDefsException(message, cause)
		0x8E -> throw TableMissingException(message, cause)
		0x8F -> throw HorizHeaderMissingException(message, cause)
		0x90 -> throw LocationsMissingException(message, cause)
		0x91 -> throw NameTableMissingException(message, cause)
		0x92 -> throw CMapTableMissingException(message, cause)
		0x93 -> throw HmtxTableMissingException(message, cause)
		0x94 -> throw PostTableMissingException(message, cause)
		0x95 -> throw InvalidHorizMetricsException(message, cause)
		0x96 -> throw InvalidCharMapFormatException(message, cause)
		0x97 -> throw InvalidPPemException(message, cause)
		0x98 -> throw InvalidVertMetricsException(message, cause)
		0x99 -> throw CouldNotFindContextException(message, cause)
		0x9A -> throw InvalidPostTableFormatException(message, cause)
		0x9B -> throw InvalidPostTableException(message, cause)
		0x9C -> throw DEFInGlyfBytecodeException(message, cause)
		0x9D -> throw MissingBitmapException(message, cause)

		/* CFF, CID, and Type 1 errors */

		0xA0 -> throw SyntaxErrorException(message, cause)
		0xA1 -> throw StackUnderflowException(message, cause)
		0xA2 -> throw IgnoreException(message, cause)
		0xA3 -> throw NoUnicodeGlyphNameException(message, cause)
		0xA4 -> throw GlyphTooBigException(message, cause)

		/* BDF errors */

		0xB0 -> throw MissingStartfontFieldException(message, cause)
		0xB1 -> throw MissingFontFieldException(message, cause)
		0xB2 -> throw MissingSizeFieldException(message, cause)
		0xB3 -> throw MissingFontboundingboxFieldException(message, cause)
		0xB4 -> throw MissingCharsFieldException(message, cause)
		0xB5 -> throw MissingStartcharFieldException(message, cause)
		0xB6 -> throw MissingEncodingFieldException(message, cause)
		0xB7 -> throw MissingBbxFieldException(message, cause)
		0xB8 -> throw BbxTooBigException(message, cause)
		0xB9 -> throw CorruptedFontHeaderException(message, cause)
		0xBA -> throw CorruptedFontGlyphsException(message, cause)
	}
}

internal fun throwFreeTypeError(code: Int, cause: Throwable? = null) {
	when (code) {
		/* generic errors */

		0x01 -> throw CannotOpenResourceException(cause = cause)
		0x02 -> throw UnknownFileFormatException(cause = cause)
		0x03 -> throw InvalidFileFormatException(cause = cause)
		0x04 -> throw InvalidVersionException(cause = cause)
		0x05 -> throw LowerModuleVersionException(cause = cause)
		0x06 -> throw InvalidArgumentException(cause = cause)
		0x07 -> throw UnimplementedFeatureException(cause = cause)
		0x08 -> throw InvalidTableException(cause = cause)
		0x09 -> throw InvalidOffsetException(cause = cause)
		0x0A -> throw ArrayTooLargeException(cause = cause)
		0x0B -> throw MissingModuleException(cause = cause)
		0x0C -> throw MissingPropertyException(cause = cause)

		/* glyph/character errors */

		0x10 -> throw InvalidGlyphIndexException(cause = cause)
		0x11 -> throw InvalidCharacterCodeException(cause = cause)
		0x12 -> throw InvalidGlyphFormatException(cause = cause)
		0x13 -> throw CannotRenderGlyphException(cause = cause)
		0x14 -> throw InvalidOutlineException(cause = cause)
		0x15 -> throw InvalidCompositeException(cause = cause)
		0x16 -> throw TooManyHintsException(cause = cause)
		0x17 -> throw InvalidPixelSizeException(cause = cause)

		/* handle errors */

		0x20 -> throw InvalidHandleException(cause = cause)
		0x21 -> throw InvalidLibraryHandleException(cause = cause)
		0x22 -> throw InvalidDriverHandleException(cause = cause)
		0x23 -> throw InvalidFaceHandleException(cause = cause)
		0x24 -> throw InvalidSizeHandleException(cause = cause)
		0x25 -> throw InvalidSlotHandleException(cause = cause)
		0x26 -> throw InvalidCharMapHandleException(cause = cause)
		0x27 -> throw InvalidCacheHandleException(cause = cause)
		0x28 -> throw InvalidStreamHandleException(cause = cause)

		/* driver errors */

		0x30 -> throw TooManyDriversException(cause = cause)
		0x31 -> throw TooManyExtensionsException(cause = cause)

		/* memory errors */

		0x40 -> throw OutOfMemoryException(cause = cause)
		0x41 -> throw UnlistedObjectException(cause = cause)

		/* stream errors */

		0x51 -> throw CannotOpenStreamException(cause = cause)
		0x52 -> throw InvalidStreamSeekException(cause = cause)
		0x53 -> throw InvalidStreamSkipException(cause = cause)
		0x54 -> throw InvalidStreamReadException(cause = cause)
		0x55 -> throw InvalidStreamOperationException(cause = cause)
		0x56 -> throw InvalidFrameOperationException(cause = cause)
		0x57 -> throw NestedFrameAccessException(cause = cause)
		0x58 -> throw InvalidFrameReadException(cause = cause)

		/* raster errors */

		0x60 -> throw RasterUninitializedException(cause = cause)
		0x61 -> throw RasterCorruptedException(cause = cause)
		0x62 -> throw RasterOverflowException(cause = cause)
		0x63 -> throw RasterNegativeHeightException(cause = cause)

		/* cache errors */

		0x70 -> throw TooManyCachesException(cause = cause)

		/* TrueType and SFNT errors */

		0x80 -> throw InvalidOpcodeException(cause = cause)
		0x81 -> throw TooFewArgumentsException(cause = cause)
		0x82 -> throw StackOverflowException(cause = cause)
		0x83 -> throw CodeOverflowException(cause = cause)
		0x84 -> throw BadArgumentException(cause = cause)
		0x85 -> throw DivideByZeroException(cause = cause)
		0x86 -> throw InvalidReferenceException(cause = cause)
		0x87 -> throw DebugOpCodeException(cause = cause)
		0x88 -> throw ENDFInExecStreamException(cause = cause)
		0x89 -> throw NestedDEFSException(cause = cause)
		0x8A -> throw InvalidCodeRangeException(cause = cause)
		0x8B -> throw ExecutionTooLongException(cause = cause)
		0x8C -> throw TooManyFunctionDefsException(cause = cause)
		0x8D -> throw TooManyInstructionDefsException(cause = cause)
		0x8E -> throw TableMissingException(cause = cause)
		0x8F -> throw HorizHeaderMissingException(cause = cause)
		0x90 -> throw LocationsMissingException(cause = cause)
		0x91 -> throw NameTableMissingException(cause = cause)
		0x92 -> throw CMapTableMissingException(cause = cause)
		0x93 -> throw HmtxTableMissingException(cause = cause)
		0x94 -> throw PostTableMissingException(cause = cause)
		0x95 -> throw InvalidHorizMetricsException(cause = cause)
		0x96 -> throw InvalidCharMapFormatException(cause = cause)
		0x97 -> throw InvalidPPemException(cause = cause)
		0x98 -> throw InvalidVertMetricsException(cause = cause)
		0x99 -> throw CouldNotFindContextException(cause = cause)
		0x9A -> throw InvalidPostTableFormatException(cause = cause)
		0x9B -> throw InvalidPostTableException(cause = cause)
		0x9C -> throw DEFInGlyfBytecodeException(cause = cause)
		0x9D -> throw MissingBitmapException(cause = cause)

		/* CFF, CID, and Type 1 errors */

		0xA0 -> throw SyntaxErrorException(cause = cause)
		0xA1 -> throw StackUnderflowException(cause = cause)
		0xA2 -> throw IgnoreException(cause = cause)
		0xA3 -> throw NoUnicodeGlyphNameException(cause = cause)
		0xA4 -> throw GlyphTooBigException(cause = cause)

		/* BDF errors */

		0xB0 -> throw MissingStartfontFieldException(cause = cause)
		0xB1 -> throw MissingFontFieldException(cause = cause)
		0xB2 -> throw MissingSizeFieldException(cause = cause)
		0xB3 -> throw MissingFontboundingboxFieldException(cause = cause)
		0xB4 -> throw MissingCharsFieldException(cause = cause)
		0xB5 -> throw MissingStartcharFieldException(cause = cause)
		0xB6 -> throw MissingEncodingFieldException(cause = cause)
		0xB7 -> throw MissingBbxFieldException(cause = cause)
		0xB8 -> throw BbxTooBigException(cause = cause)
		0xB9 -> throw CorruptedFontHeaderException(cause = cause)
		0xBA -> throw CorruptedFontGlyphsException(cause = cause)
	}
}
