From 05c367aec2be624d233951ad40a20fc48890ccf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20Zim=C3=A1nyi?= Date: Wed, 2 Sep 2026 22:17:00 +0200 Subject: [PATCH] Generate the error taxonomy from the catalog's error contract MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MEOS raises through one mechanism — `meos_error(errlevel, errcode, fmt, ...)` over the `errorCode` enum — and the catalog carries that enum verbatim as `objectModel.errors.codes`, drift-gated against `meos.h`, with the meaning of each code beside it. `objectgen.py` projects it: the `MEOSErrorCodes` enum, one exception class per code, and the handler that turns the code MEOS reports into the exception for it, each carrying the meaning MEOS states as its documentation. The taxonomy is complete by construction. A code the binding does not name reaches the caller as `MEOSInternalErrorException`, and seven codes MEOS raises take that path without a class of their own — `MEOS_ERR_OUT_OF_MEMORY`, `MEOS_ERR_FEATURE_NOT_SUPPORTED`, `MEOS_ERR_INDETERMINATE_COLLATION`, `MEOS_ERR_SYNTAX_ERROR`, `MEOS_ERR_NULL_RESULT`, `MEOS_ERR_SQL_JSON_ERROR` and `MEOS_ERR_INVALID_REGULAR_EXPRESSION` — leaving a caller unable to tell an unsupported feature from an internal fault. Deriving the set from the enum gives each of them its own class. The names are the ones the enum gives: `MEOS_ERR_INVALID_ARG_VALUE` reads `InvalidArgValue`, and the acronym runs the catalog's own camelCase keeps — WKB, MFJSON, GEOJSON, SQL, JSON — stay upper-case. The dispatch is one switch expression over the code, which cannot fall through the arm it selects. --- MEOS.NET.Tests/GeneratedObjectLayerTests.cs | 2 +- MEOS.NET/Errors/MEOSErrorCodes.cs | 29 ---- MEOS.NET/Errors/MEOSErrorCodes.g.cs | 91 ++++++++++ MEOS.NET/Errors/MEOSErrorHandling.cs | 123 -------------- MEOS.NET/Errors/MEOSErrorHandling.g.cs | 63 +++++++ .../MEOSAggregationErrorException.g.cs | 15 ++ .../Exceptions/MEOSAggregationException.cs | 11 -- .../MEOSBadGeoJSONInputException.cs | 11 -- .../MEOSBadGeoJSONOutputException.cs | 11 -- .../Exceptions/MEOSBadMFJSONInputException.cs | 11 -- .../MEOSBadMFJSONOutputException.cs | 11 -- .../Exceptions/MEOSBadTextInputException.cs | 11 -- .../Exceptions/MEOSBadTextOutputException.cs | 11 -- .../Exceptions/MEOSBadWKBInputException.cs | 11 -- .../Exceptions/MEOSBadWKBOutputException.cs | 11 -- .../MEOSDirectoryErrorException.g.cs | 15 ++ MEOS.NET/Exceptions/MEOSDirectoryException.cs | 11 -- .../Exceptions/MEOSDivisionByZeroException.cs | 11 -- .../MEOSDivisionByZeroException.g.cs | 15 ++ .../{MEOSException.cs => MEOSException.g.cs} | 39 +++-- .../MEOSFeatureNotSupportedException.g.cs | 15 ++ .../Exceptions/MEOSFileErrorException.g.cs | 15 ++ MEOS.NET/Exceptions/MEOSFileException.cs | 11 -- .../Exceptions/MEOSGEOJSONInputException.g.cs | 15 ++ .../MEOSGEOJSONOutputException.g.cs | 15 ++ .../MEOSIndeterminateCollationException.g.cs | 15 ++ .../MEOSInternalErrorException.g.cs | 15 ++ .../MEOSInternalTypeErrorException.cs | 11 -- .../MEOSInternalTypeErrorException.g.cs | 15 ++ .../Exceptions/MEOSInvalidArgException.g.cs | 15 ++ .../MEOSInvalidArgTypeException.g.cs | 15 ++ .../MEOSInvalidArgValueException.g.cs | 15 ++ .../MEOSInvalidArgumentException.cs | 11 -- .../MEOSInvalidArgumentTypeException.cs | 11 -- .../MEOSInvalidArgumentValueException.cs | 11 -- ...MEOSInvalidRegularExpressionException.g.cs | 15 ++ .../Exceptions/MEOSMFJSONInputException.g.cs | 15 ++ .../Exceptions/MEOSMFJSONOutputException.g.cs | 15 ++ .../MEOSMemoryAllocErrorException.g.cs | 15 ++ .../MEOSMemoryAllocationException.cs | 11 -- .../Exceptions/MEOSNullResultException.g.cs | 15 ++ .../Exceptions/MEOSOutOfMemoryException.g.cs | 15 ++ .../Exceptions/MEOSSQLJSONErrorException.g.cs | 15 ++ .../Exceptions/MEOSSyntaxErrorException.g.cs | 15 ++ .../Exceptions/MEOSTextInputException.g.cs | 15 ++ .../Exceptions/MEOSTextOutputException.g.cs | 15 ++ .../MEOSUnspecifiedInternalException.cs | 11 -- .../MEOSValueOutOfRangeException.cs | 11 -- .../MEOSValueOutOfRangeException.g.cs | 15 ++ .../Exceptions/MEOSWKBInputException.g.cs | 15 ++ .../Exceptions/MEOSWKBOutputException.g.cs | 15 ++ MEOS.NET/Types/Temporal/Temporal.cs | 6 +- tools/objectgen.py | 158 ++++++++++++++++++ 53 files changed, 728 insertions(+), 382 deletions(-) delete mode 100644 MEOS.NET/Errors/MEOSErrorCodes.cs create mode 100644 MEOS.NET/Errors/MEOSErrorCodes.g.cs delete mode 100644 MEOS.NET/Errors/MEOSErrorHandling.cs create mode 100644 MEOS.NET/Errors/MEOSErrorHandling.g.cs create mode 100644 MEOS.NET/Exceptions/MEOSAggregationErrorException.g.cs delete mode 100644 MEOS.NET/Exceptions/MEOSAggregationException.cs delete mode 100644 MEOS.NET/Exceptions/MEOSBadGeoJSONInputException.cs delete mode 100644 MEOS.NET/Exceptions/MEOSBadGeoJSONOutputException.cs delete mode 100644 MEOS.NET/Exceptions/MEOSBadMFJSONInputException.cs delete mode 100644 MEOS.NET/Exceptions/MEOSBadMFJSONOutputException.cs delete mode 100644 MEOS.NET/Exceptions/MEOSBadTextInputException.cs delete mode 100644 MEOS.NET/Exceptions/MEOSBadTextOutputException.cs delete mode 100644 MEOS.NET/Exceptions/MEOSBadWKBInputException.cs delete mode 100644 MEOS.NET/Exceptions/MEOSBadWKBOutputException.cs create mode 100644 MEOS.NET/Exceptions/MEOSDirectoryErrorException.g.cs delete mode 100644 MEOS.NET/Exceptions/MEOSDirectoryException.cs delete mode 100644 MEOS.NET/Exceptions/MEOSDivisionByZeroException.cs create mode 100644 MEOS.NET/Exceptions/MEOSDivisionByZeroException.g.cs rename MEOS.NET/Exceptions/{MEOSException.cs => MEOSException.g.cs} (64%) create mode 100644 MEOS.NET/Exceptions/MEOSFeatureNotSupportedException.g.cs create mode 100644 MEOS.NET/Exceptions/MEOSFileErrorException.g.cs delete mode 100644 MEOS.NET/Exceptions/MEOSFileException.cs create mode 100644 MEOS.NET/Exceptions/MEOSGEOJSONInputException.g.cs create mode 100644 MEOS.NET/Exceptions/MEOSGEOJSONOutputException.g.cs create mode 100644 MEOS.NET/Exceptions/MEOSIndeterminateCollationException.g.cs create mode 100644 MEOS.NET/Exceptions/MEOSInternalErrorException.g.cs delete mode 100644 MEOS.NET/Exceptions/MEOSInternalTypeErrorException.cs create mode 100644 MEOS.NET/Exceptions/MEOSInternalTypeErrorException.g.cs create mode 100644 MEOS.NET/Exceptions/MEOSInvalidArgException.g.cs create mode 100644 MEOS.NET/Exceptions/MEOSInvalidArgTypeException.g.cs create mode 100644 MEOS.NET/Exceptions/MEOSInvalidArgValueException.g.cs delete mode 100644 MEOS.NET/Exceptions/MEOSInvalidArgumentException.cs delete mode 100644 MEOS.NET/Exceptions/MEOSInvalidArgumentTypeException.cs delete mode 100644 MEOS.NET/Exceptions/MEOSInvalidArgumentValueException.cs create mode 100644 MEOS.NET/Exceptions/MEOSInvalidRegularExpressionException.g.cs create mode 100644 MEOS.NET/Exceptions/MEOSMFJSONInputException.g.cs create mode 100644 MEOS.NET/Exceptions/MEOSMFJSONOutputException.g.cs create mode 100644 MEOS.NET/Exceptions/MEOSMemoryAllocErrorException.g.cs delete mode 100644 MEOS.NET/Exceptions/MEOSMemoryAllocationException.cs create mode 100644 MEOS.NET/Exceptions/MEOSNullResultException.g.cs create mode 100644 MEOS.NET/Exceptions/MEOSOutOfMemoryException.g.cs create mode 100644 MEOS.NET/Exceptions/MEOSSQLJSONErrorException.g.cs create mode 100644 MEOS.NET/Exceptions/MEOSSyntaxErrorException.g.cs create mode 100644 MEOS.NET/Exceptions/MEOSTextInputException.g.cs create mode 100644 MEOS.NET/Exceptions/MEOSTextOutputException.g.cs delete mode 100644 MEOS.NET/Exceptions/MEOSUnspecifiedInternalException.cs delete mode 100644 MEOS.NET/Exceptions/MEOSValueOutOfRangeException.cs create mode 100644 MEOS.NET/Exceptions/MEOSValueOutOfRangeException.g.cs create mode 100644 MEOS.NET/Exceptions/MEOSWKBInputException.g.cs create mode 100644 MEOS.NET/Exceptions/MEOSWKBOutputException.g.cs diff --git a/MEOS.NET.Tests/GeneratedObjectLayerTests.cs b/MEOS.NET.Tests/GeneratedObjectLayerTests.cs index ba75bac..3296648 100644 --- a/MEOS.NET.Tests/GeneratedObjectLayerTests.cs +++ b/MEOS.NET.Tests/GeneratedObjectLayerTests.cs @@ -131,7 +131,7 @@ public void MakingAnInstantFromAValueAndAMomentReadsBack() [TestMethod] public void MalformedTextRaisesTheMeosError() { - MEOSException raised = Assert.ThrowsException( + MEOSException raised = Assert.ThrowsException( () => TFloat.In("e" + Instant)); StringAssert.Contains(raised.Message, "e25.0"); diff --git a/MEOS.NET/Errors/MEOSErrorCodes.cs b/MEOS.NET/Errors/MEOSErrorCodes.cs deleted file mode 100644 index da90336..0000000 --- a/MEOS.NET/Errors/MEOSErrorCodes.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace MEOS.NET.Errors -{ - public enum MEOSErrorCodes - { - Success = 0, // Successful operation - - UnspecifiedInternalError = 1, // Unspecified internal error - InternalTypeError = 2, // Internal type error - ValueOutOfRange = 3, // Internal out of range error - DivisionByZero = 4, // Internal division by zero error - MemoryAllocationError = 5, // Internal malloc error - AggregationError = 6, // Internal aggregation error - DirectoryError = 7, // Internal directory error - FileError = 8, // Internal file error - - InvalidArgument = 10, // Invalid argument - InvalidArgumentType = 11, // Invalid argument type - InvalidArgumentValue = 12, // Invalid argument value - - BadMFJSONInput = 20, // MFJSON input error - BadMFJSONOutput = 21, // MFJSON output error - BadTextInput = 22, // Text input error - BadTextOutput = 23, // Text output error - BadWellKnownBinaryInput = 24, // WKB input error - BadWellKnownBinaryOutput = 25, // WKB output error - BadGeoJSONInput = 26, // GEOJSON input error - BadGeoJSONOutput = 27, // GEOJSON output error - } -} diff --git a/MEOS.NET/Errors/MEOSErrorCodes.g.cs b/MEOS.NET/Errors/MEOSErrorCodes.g.cs new file mode 100644 index 0000000..51cd16d --- /dev/null +++ b/MEOS.NET/Errors/MEOSErrorCodes.g.cs @@ -0,0 +1,91 @@ +#nullable enable + +namespace MEOS.NET.Errors +{ + /// Every code MEOS raises with, and what each one means. + [System.CodeDom.Compiler.GeneratedCode("MEOS.NET.ObjectGen", "0.1.0")] + public enum MEOSErrorCodes + { + /// Successful operation (MEOS_SUCCESS). + Success = 0, + + /// Unspecified internal error (MEOS_ERR_INTERNAL_ERROR). + InternalError = 1, + + /// Internal type error (MEOS_ERR_INTERNAL_TYPE_ERROR). + InternalTypeError = 2, + + /// Internal out of range error (MEOS_ERR_VALUE_OUT_OF_RANGE). + ValueOutOfRange = 3, + + /// Internal division by zero error (MEOS_ERR_DIVISION_BY_ZERO). + DivisionByZero = 4, + + /// Internal malloc error (MEOS_ERR_MEMORY_ALLOC_ERROR). + MemoryAllocError = 5, + + /// Internal aggregation error (MEOS_ERR_AGGREGATION_ERROR). + AggregationError = 6, + + /// Internal directory error (MEOS_ERR_DIRECTORY_ERROR). + DirectoryError = 7, + + /// Internal file error (MEOS_ERR_FILE_ERROR). + FileError = 8, + + /// Out of memory error (MEOS_ERR_OUT_OF_MEMORY). + OutOfMemory = 9, + + /// Invalid argument (MEOS_ERR_INVALID_ARG). + InvalidArg = 10, + + /// Invalid argument type (MEOS_ERR_INVALID_ARG_TYPE). + InvalidArgType = 11, + + /// Invalid argument value (MEOS_ERR_INVALID_ARG_VALUE). + InvalidArgValue = 12, + + /// Feature not currently supported (MEOS_ERR_FEATURE_NOT_SUPPORTED). + FeatureNotSupported = 13, + + /// Indeterminate collation (MEOS_ERR_INDETERMINATE_COLLATION). + IndeterminateCollation = 14, + + /// Syntax error (MEOS_ERR_SYNTAX_ERROR). + SyntaxError = 15, + + /// Operation returned null (MEOS_ERR_NULL_RESULT). + NullResult = 16, + + /// MFJSON input error (MEOS_ERR_MFJSON_INPUT). + MFJSONInput = 20, + + /// MFJSON output error (MEOS_ERR_MFJSON_OUTPUT). + MFJSONOutput = 21, + + /// Text input error (MEOS_ERR_TEXT_INPUT). + TextInput = 22, + + /// Text output error (MEOS_ERR_TEXT_OUTPUT). + TextOutput = 23, + + /// WKB input error (MEOS_ERR_WKB_INPUT). + WKBInput = 24, + + /// WKB output error (MEOS_ERR_WKB_OUTPUT). + WKBOutput = 25, + + /// GEOJSON input error (MEOS_ERR_GEOJSON_INPUT). + GEOJSONInput = 26, + + /// GEOJSON output error (MEOS_ERR_GEOJSON_OUTPUT). + GEOJSONOutput = 27, + + /// SQL JSON error (MEOS_ERR_SQL_JSON_ERROR). + SQLJSONError = 28, + + /// Regular expression error (MEOS_ERR_INVALID_REGULAR_EXPRESSION). + InvalidRegularExpression = 29, + + } +} diff --git a/MEOS.NET/Errors/MEOSErrorHandling.cs b/MEOS.NET/Errors/MEOSErrorHandling.cs deleted file mode 100644 index ed865ab..0000000 --- a/MEOS.NET/Errors/MEOSErrorHandling.cs +++ /dev/null @@ -1,123 +0,0 @@ -using MEOS.NET.Exceptions; - -namespace MEOS.NET.Errors -{ - internal static class MEOSErrorHandling - { - private static MEOSException? currentException = null; - - internal static void CheckError() - { - if (currentException is null) - { - return; - } - - var e = currentException; - currentException = null; - - throw e; - } - - internal static void InternalErrorHandler(int level, int errorCode, string message) - { - // If MEOS error code is not defined in our C# code, - // We register an unspecified exception to guarantee code-safety - if (!Enum.IsDefined(typeof(MEOSErrorCodes), errorCode)) - { - RegisterException(new MEOSUnspecifiedInternalException(level, MEOSErrorCodes.UnspecifiedInternalError, message)); - } - - var code = (MEOSErrorCodes)errorCode; - - switch (code) - { - case MEOSErrorCodes.Success: - return; - - case MEOSErrorCodes.UnspecifiedInternalError: - RegisterException(new MEOSUnspecifiedInternalException(level, code, message)); - break; - - case MEOSErrorCodes.InternalTypeError: - RegisterException(new MEOSInternalTypeErrorException(level, code, message)); - break; - - case MEOSErrorCodes.ValueOutOfRange: - RegisterException(new MEOSValueOutOfRangeException(level, code, message)); - break; - - case MEOSErrorCodes.DivisionByZero: - RegisterException(new MEOSDivisionByZeroException(level, code, message)); - break; - - case MEOSErrorCodes.MemoryAllocationError: - RegisterException(new MEOSMemoryAllocationException(level, code, message)); - break; - - case MEOSErrorCodes.AggregationError: - RegisterException(new MEOSAggregationException(level, code, message)); - break; - - case MEOSErrorCodes.DirectoryError: - RegisterException(new MEOSDirectoryException(level, code, message)); - break; - - case MEOSErrorCodes.FileError: - RegisterException(new MEOSFileException(level, code, message)); - break; - - case MEOSErrorCodes.InvalidArgument: - RegisterException(new MEOSInvalidArgumentException(level, code, message)); - break; - - case MEOSErrorCodes.InvalidArgumentType: - RegisterException(new MEOSInvalidArgumentTypeException(level, code, message)); - break; - - case MEOSErrorCodes.InvalidArgumentValue: - RegisterException(new MEOSInvalidArgumentValueException(level, code, message)); - break; - - case MEOSErrorCodes.BadMFJSONInput: - RegisterException(new MEOSBadMFJSONInputException(level, code, message)); - break; - - case MEOSErrorCodes.BadMFJSONOutput: - RegisterException(new MEOSBadMFJSONOutputException(level, code, message)); - break; - - case MEOSErrorCodes.BadTextInput: - RegisterException(new MEOSBadTextInputException(level, code, message)); - break; - - case MEOSErrorCodes.BadTextOutput: - RegisterException(new MEOSBadTextOutputException(level, code, message)); - break; - - case MEOSErrorCodes.BadWellKnownBinaryInput: - RegisterException(new MEOSBadWKBInputException(level, code, message)); - break; - - case MEOSErrorCodes.BadWellKnownBinaryOutput: - RegisterException(new MEOSBadWKBOutputException(level, code, message)); - break; - - case MEOSErrorCodes.BadGeoJSONInput: - RegisterException(new MEOSBadGeoJSONInputException(level, code, message)); - break; - - case MEOSErrorCodes.BadGeoJSONOutput: - RegisterException(new MEOSBadGeoJSONOutputException(level, code, message)); - break; - - default: - RegisterException(new MEOSUnspecifiedInternalException(level, code, message)); - break; - } - } - - private static void RegisterException(MEOSException exception) - => currentException = exception; - } -} diff --git a/MEOS.NET/Errors/MEOSErrorHandling.g.cs b/MEOS.NET/Errors/MEOSErrorHandling.g.cs new file mode 100644 index 0000000..a41cde0 --- /dev/null +++ b/MEOS.NET/Errors/MEOSErrorHandling.g.cs @@ -0,0 +1,63 @@ +#nullable enable + +using MEOS.NET.Exceptions; + +namespace MEOS.NET.Errors +{ + /// Turns the error MEOS reports into the exception for its code. + [System.CodeDom.Compiler.GeneratedCode("MEOS.NET.ObjectGen", "0.1.0")] + internal static class MEOSErrorHandling + { + private static MEOSException? pending; + + /// Raise what MEOS reported since the last check, if anything. + internal static void CheckError() + { + if (pending is null) + { + return; + } + + var raised = pending; + pending = null; + throw raised; + } + + /// The handler MEOS calls; it records, and CheckError raises. + internal static void InternalErrorHandler(int level, int errorCode, string message) + => pending = errorCode switch + { + 0 => null, // MEOS_SUCCESS + 1 => new MEOSInternalErrorException(level, MEOSErrorCodes.InternalError, message), + 2 => new MEOSInternalTypeErrorException(level, MEOSErrorCodes.InternalTypeError, message), + 3 => new MEOSValueOutOfRangeException(level, MEOSErrorCodes.ValueOutOfRange, message), + 4 => new MEOSDivisionByZeroException(level, MEOSErrorCodes.DivisionByZero, message), + 5 => new MEOSMemoryAllocErrorException(level, MEOSErrorCodes.MemoryAllocError, message), + 6 => new MEOSAggregationErrorException(level, MEOSErrorCodes.AggregationError, message), + 7 => new MEOSDirectoryErrorException(level, MEOSErrorCodes.DirectoryError, message), + 8 => new MEOSFileErrorException(level, MEOSErrorCodes.FileError, message), + 9 => new MEOSOutOfMemoryException(level, MEOSErrorCodes.OutOfMemory, message), + 10 => new MEOSInvalidArgException(level, MEOSErrorCodes.InvalidArg, message), + 11 => new MEOSInvalidArgTypeException(level, MEOSErrorCodes.InvalidArgType, message), + 12 => new MEOSInvalidArgValueException(level, MEOSErrorCodes.InvalidArgValue, message), + 13 => new MEOSFeatureNotSupportedException(level, MEOSErrorCodes.FeatureNotSupported, message), + 14 => new MEOSIndeterminateCollationException(level, MEOSErrorCodes.IndeterminateCollation, message), + 15 => new MEOSSyntaxErrorException(level, MEOSErrorCodes.SyntaxError, message), + 16 => new MEOSNullResultException(level, MEOSErrorCodes.NullResult, message), + 20 => new MEOSMFJSONInputException(level, MEOSErrorCodes.MFJSONInput, message), + 21 => new MEOSMFJSONOutputException(level, MEOSErrorCodes.MFJSONOutput, message), + 22 => new MEOSTextInputException(level, MEOSErrorCodes.TextInput, message), + 23 => new MEOSTextOutputException(level, MEOSErrorCodes.TextOutput, message), + 24 => new MEOSWKBInputException(level, MEOSErrorCodes.WKBInput, message), + 25 => new MEOSWKBOutputException(level, MEOSErrorCodes.WKBOutput, message), + 26 => new MEOSGEOJSONInputException(level, MEOSErrorCodes.GEOJSONInput, message), + 27 => new MEOSGEOJSONOutputException(level, MEOSErrorCodes.GEOJSONOutput, message), + 28 => new MEOSSQLJSONErrorException(level, MEOSErrorCodes.SQLJSONError, message), + 29 => new MEOSInvalidRegularExpressionException(level, MEOSErrorCodes.InvalidRegularExpression, message), + // A code this binding does not name is still an error MEOS + // raised, so it reaches the caller rather than being dropped. + _ => new MEOSInternalErrorException( + level, MEOSErrorCodes.InternalError, message), + }; + } +} diff --git a/MEOS.NET/Exceptions/MEOSAggregationErrorException.g.cs b/MEOS.NET/Exceptions/MEOSAggregationErrorException.g.cs new file mode 100644 index 0000000..1273413 --- /dev/null +++ b/MEOS.NET/Exceptions/MEOSAggregationErrorException.g.cs @@ -0,0 +1,15 @@ +#nullable enable + +using MEOS.NET.Errors; + +namespace MEOS.NET.Exceptions +{ + /// Internal aggregation error (MEOS_ERR_AGGREGATION_ERROR). + [System.CodeDom.Compiler.GeneratedCode("MEOS.NET.ObjectGen", "0.1.0")] + public class MEOSAggregationErrorException : MEOSException + { + internal MEOSAggregationErrorException(int level, MEOSErrorCodes code, string message) + : base(level, code, message) + { } + } +} diff --git a/MEOS.NET/Exceptions/MEOSAggregationException.cs b/MEOS.NET/Exceptions/MEOSAggregationException.cs deleted file mode 100644 index f22b7f0..0000000 --- a/MEOS.NET/Exceptions/MEOSAggregationException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using MEOS.NET.Errors; - -namespace MEOS.NET.Exceptions -{ - public class MEOSAggregationException : MEOSException - { - internal MEOSAggregationException(int level, MEOSErrorCodes code, string message) - : base(level, code, message) - { } - } -} diff --git a/MEOS.NET/Exceptions/MEOSBadGeoJSONInputException.cs b/MEOS.NET/Exceptions/MEOSBadGeoJSONInputException.cs deleted file mode 100644 index 2ecd0f5..0000000 --- a/MEOS.NET/Exceptions/MEOSBadGeoJSONInputException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using MEOS.NET.Errors; - -namespace MEOS.NET.Exceptions -{ - public class MEOSBadGeoJSONInputException : MEOSException - { - internal MEOSBadGeoJSONInputException(int level, MEOSErrorCodes code, string message) - : base(level, code, message) - { } - } -} diff --git a/MEOS.NET/Exceptions/MEOSBadGeoJSONOutputException.cs b/MEOS.NET/Exceptions/MEOSBadGeoJSONOutputException.cs deleted file mode 100644 index 64eeafc..0000000 --- a/MEOS.NET/Exceptions/MEOSBadGeoJSONOutputException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using MEOS.NET.Errors; - -namespace MEOS.NET.Exceptions -{ - public class MEOSBadGeoJSONOutputException : MEOSException - { - internal MEOSBadGeoJSONOutputException(int level, MEOSErrorCodes code, string message) - : base(level, code, message) - { } - } -} diff --git a/MEOS.NET/Exceptions/MEOSBadMFJSONInputException.cs b/MEOS.NET/Exceptions/MEOSBadMFJSONInputException.cs deleted file mode 100644 index b6e1860..0000000 --- a/MEOS.NET/Exceptions/MEOSBadMFJSONInputException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using MEOS.NET.Errors; - -namespace MEOS.NET.Exceptions -{ - public class MEOSBadMFJSONInputException : MEOSException - { - internal MEOSBadMFJSONInputException(int level, MEOSErrorCodes code, string message) - : base(level, code, message) - { } - } -} diff --git a/MEOS.NET/Exceptions/MEOSBadMFJSONOutputException.cs b/MEOS.NET/Exceptions/MEOSBadMFJSONOutputException.cs deleted file mode 100644 index 2bc3c81..0000000 --- a/MEOS.NET/Exceptions/MEOSBadMFJSONOutputException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using MEOS.NET.Errors; - -namespace MEOS.NET.Exceptions -{ - public class MEOSBadMFJSONOutputException : MEOSException - { - internal MEOSBadMFJSONOutputException(int level, MEOSErrorCodes code, string message) - : base(level, code, message) - { } - } -} diff --git a/MEOS.NET/Exceptions/MEOSBadTextInputException.cs b/MEOS.NET/Exceptions/MEOSBadTextInputException.cs deleted file mode 100644 index eebcd27..0000000 --- a/MEOS.NET/Exceptions/MEOSBadTextInputException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using MEOS.NET.Errors; - -namespace MEOS.NET.Exceptions -{ - public class MEOSBadTextInputException : MEOSException - { - internal MEOSBadTextInputException(int level, MEOSErrorCodes code, string message) - : base(level, code, message) - { } - } -} diff --git a/MEOS.NET/Exceptions/MEOSBadTextOutputException.cs b/MEOS.NET/Exceptions/MEOSBadTextOutputException.cs deleted file mode 100644 index 0e05366..0000000 --- a/MEOS.NET/Exceptions/MEOSBadTextOutputException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using MEOS.NET.Errors; - -namespace MEOS.NET.Exceptions -{ - public class MEOSBadTextOutputException : MEOSException - { - internal MEOSBadTextOutputException(int level, MEOSErrorCodes code, string message) - : base(level, code, message) - { } - } -} diff --git a/MEOS.NET/Exceptions/MEOSBadWKBInputException.cs b/MEOS.NET/Exceptions/MEOSBadWKBInputException.cs deleted file mode 100644 index 6af274a..0000000 --- a/MEOS.NET/Exceptions/MEOSBadWKBInputException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using MEOS.NET.Errors; - -namespace MEOS.NET.Exceptions -{ - public class MEOSBadWKBInputException : MEOSException - { - internal MEOSBadWKBInputException(int level, MEOSErrorCodes code, string message) - : base(level, code, message) - { } - } -} diff --git a/MEOS.NET/Exceptions/MEOSBadWKBOutputException.cs b/MEOS.NET/Exceptions/MEOSBadWKBOutputException.cs deleted file mode 100644 index 11cda3e..0000000 --- a/MEOS.NET/Exceptions/MEOSBadWKBOutputException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using MEOS.NET.Errors; - -namespace MEOS.NET.Exceptions -{ - public class MEOSBadWKBOutputException : MEOSException - { - internal MEOSBadWKBOutputException(int level, MEOSErrorCodes code, string message) - : base(level, code, message) - { } - } -} diff --git a/MEOS.NET/Exceptions/MEOSDirectoryErrorException.g.cs b/MEOS.NET/Exceptions/MEOSDirectoryErrorException.g.cs new file mode 100644 index 0000000..aa8045c --- /dev/null +++ b/MEOS.NET/Exceptions/MEOSDirectoryErrorException.g.cs @@ -0,0 +1,15 @@ +#nullable enable + +using MEOS.NET.Errors; + +namespace MEOS.NET.Exceptions +{ + /// Internal directory error (MEOS_ERR_DIRECTORY_ERROR). + [System.CodeDom.Compiler.GeneratedCode("MEOS.NET.ObjectGen", "0.1.0")] + public class MEOSDirectoryErrorException : MEOSException + { + internal MEOSDirectoryErrorException(int level, MEOSErrorCodes code, string message) + : base(level, code, message) + { } + } +} diff --git a/MEOS.NET/Exceptions/MEOSDirectoryException.cs b/MEOS.NET/Exceptions/MEOSDirectoryException.cs deleted file mode 100644 index a3dce04..0000000 --- a/MEOS.NET/Exceptions/MEOSDirectoryException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using MEOS.NET.Errors; - -namespace MEOS.NET.Exceptions -{ - public class MEOSDirectoryException : MEOSException - { - internal MEOSDirectoryException(int level, MEOSErrorCodes code, string message) - : base(level, code, message) - { } - } -} diff --git a/MEOS.NET/Exceptions/MEOSDivisionByZeroException.cs b/MEOS.NET/Exceptions/MEOSDivisionByZeroException.cs deleted file mode 100644 index cbeaf8e..0000000 --- a/MEOS.NET/Exceptions/MEOSDivisionByZeroException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using MEOS.NET.Errors; - -namespace MEOS.NET.Exceptions -{ - public class MEOSDivisionByZeroException : MEOSException - { - internal MEOSDivisionByZeroException(int level, MEOSErrorCodes code, string message) - : base(level, code, message) - { } - } -} diff --git a/MEOS.NET/Exceptions/MEOSDivisionByZeroException.g.cs b/MEOS.NET/Exceptions/MEOSDivisionByZeroException.g.cs new file mode 100644 index 0000000..ad338a3 --- /dev/null +++ b/MEOS.NET/Exceptions/MEOSDivisionByZeroException.g.cs @@ -0,0 +1,15 @@ +#nullable enable + +using MEOS.NET.Errors; + +namespace MEOS.NET.Exceptions +{ + /// Internal division by zero error (MEOS_ERR_DIVISION_BY_ZERO). + [System.CodeDom.Compiler.GeneratedCode("MEOS.NET.ObjectGen", "0.1.0")] + public class MEOSDivisionByZeroException : MEOSException + { + internal MEOSDivisionByZeroException(int level, MEOSErrorCodes code, string message) + : base(level, code, message) + { } + } +} diff --git a/MEOS.NET/Exceptions/MEOSException.cs b/MEOS.NET/Exceptions/MEOSException.g.cs similarity index 64% rename from MEOS.NET/Exceptions/MEOSException.cs rename to MEOS.NET/Exceptions/MEOSException.g.cs index cdf85e5..5f3c9b9 100644 --- a/MEOS.NET/Exceptions/MEOSException.cs +++ b/MEOS.NET/Exceptions/MEOSException.g.cs @@ -1,17 +1,22 @@ -using MEOS.NET.Errors; - -namespace MEOS.NET.Exceptions -{ - public abstract class MEOSException : Exception - { - public int Level { get; init; } - public MEOSErrorCodes Code { get; init; } - - internal MEOSException(int level, MEOSErrorCodes code, string message) - : base(message) - { - this.Level = level; - this.Code = code; - } - } -} +#nullable enable + +using MEOS.NET.Errors; + +namespace MEOS.NET.Exceptions +{ + /// An error MEOS raised, with the code and level it raised it at. + [System.CodeDom.Compiler.GeneratedCode("MEOS.NET.ObjectGen", "0.1.0")] + public abstract class MEOSException : Exception + { + public int Level { get; init; } + + public MEOSErrorCodes Code { get; init; } + + internal MEOSException(int level, MEOSErrorCodes code, string message) + : base(message) + { + this.Level = level; + this.Code = code; + } + } +} diff --git a/MEOS.NET/Exceptions/MEOSFeatureNotSupportedException.g.cs b/MEOS.NET/Exceptions/MEOSFeatureNotSupportedException.g.cs new file mode 100644 index 0000000..922d084 --- /dev/null +++ b/MEOS.NET/Exceptions/MEOSFeatureNotSupportedException.g.cs @@ -0,0 +1,15 @@ +#nullable enable + +using MEOS.NET.Errors; + +namespace MEOS.NET.Exceptions +{ + /// Feature not currently supported (MEOS_ERR_FEATURE_NOT_SUPPORTED). + [System.CodeDom.Compiler.GeneratedCode("MEOS.NET.ObjectGen", "0.1.0")] + public class MEOSFeatureNotSupportedException : MEOSException + { + internal MEOSFeatureNotSupportedException(int level, MEOSErrorCodes code, string message) + : base(level, code, message) + { } + } +} diff --git a/MEOS.NET/Exceptions/MEOSFileErrorException.g.cs b/MEOS.NET/Exceptions/MEOSFileErrorException.g.cs new file mode 100644 index 0000000..e4ffb79 --- /dev/null +++ b/MEOS.NET/Exceptions/MEOSFileErrorException.g.cs @@ -0,0 +1,15 @@ +#nullable enable + +using MEOS.NET.Errors; + +namespace MEOS.NET.Exceptions +{ + /// Internal file error (MEOS_ERR_FILE_ERROR). + [System.CodeDom.Compiler.GeneratedCode("MEOS.NET.ObjectGen", "0.1.0")] + public class MEOSFileErrorException : MEOSException + { + internal MEOSFileErrorException(int level, MEOSErrorCodes code, string message) + : base(level, code, message) + { } + } +} diff --git a/MEOS.NET/Exceptions/MEOSFileException.cs b/MEOS.NET/Exceptions/MEOSFileException.cs deleted file mode 100644 index b7caf15..0000000 --- a/MEOS.NET/Exceptions/MEOSFileException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using MEOS.NET.Errors; - -namespace MEOS.NET.Exceptions -{ - public class MEOSFileException : MEOSException - { - internal MEOSFileException(int level, MEOSErrorCodes code, string message) - : base(level, code, message) - { } - } -} diff --git a/MEOS.NET/Exceptions/MEOSGEOJSONInputException.g.cs b/MEOS.NET/Exceptions/MEOSGEOJSONInputException.g.cs new file mode 100644 index 0000000..18e5e0e --- /dev/null +++ b/MEOS.NET/Exceptions/MEOSGEOJSONInputException.g.cs @@ -0,0 +1,15 @@ +#nullable enable + +using MEOS.NET.Errors; + +namespace MEOS.NET.Exceptions +{ + /// GEOJSON input error (MEOS_ERR_GEOJSON_INPUT). + [System.CodeDom.Compiler.GeneratedCode("MEOS.NET.ObjectGen", "0.1.0")] + public class MEOSGEOJSONInputException : MEOSException + { + internal MEOSGEOJSONInputException(int level, MEOSErrorCodes code, string message) + : base(level, code, message) + { } + } +} diff --git a/MEOS.NET/Exceptions/MEOSGEOJSONOutputException.g.cs b/MEOS.NET/Exceptions/MEOSGEOJSONOutputException.g.cs new file mode 100644 index 0000000..9755b99 --- /dev/null +++ b/MEOS.NET/Exceptions/MEOSGEOJSONOutputException.g.cs @@ -0,0 +1,15 @@ +#nullable enable + +using MEOS.NET.Errors; + +namespace MEOS.NET.Exceptions +{ + /// GEOJSON output error (MEOS_ERR_GEOJSON_OUTPUT). + [System.CodeDom.Compiler.GeneratedCode("MEOS.NET.ObjectGen", "0.1.0")] + public class MEOSGEOJSONOutputException : MEOSException + { + internal MEOSGEOJSONOutputException(int level, MEOSErrorCodes code, string message) + : base(level, code, message) + { } + } +} diff --git a/MEOS.NET/Exceptions/MEOSIndeterminateCollationException.g.cs b/MEOS.NET/Exceptions/MEOSIndeterminateCollationException.g.cs new file mode 100644 index 0000000..b2be314 --- /dev/null +++ b/MEOS.NET/Exceptions/MEOSIndeterminateCollationException.g.cs @@ -0,0 +1,15 @@ +#nullable enable + +using MEOS.NET.Errors; + +namespace MEOS.NET.Exceptions +{ + /// Indeterminate collation (MEOS_ERR_INDETERMINATE_COLLATION). + [System.CodeDom.Compiler.GeneratedCode("MEOS.NET.ObjectGen", "0.1.0")] + public class MEOSIndeterminateCollationException : MEOSException + { + internal MEOSIndeterminateCollationException(int level, MEOSErrorCodes code, string message) + : base(level, code, message) + { } + } +} diff --git a/MEOS.NET/Exceptions/MEOSInternalErrorException.g.cs b/MEOS.NET/Exceptions/MEOSInternalErrorException.g.cs new file mode 100644 index 0000000..d705ec2 --- /dev/null +++ b/MEOS.NET/Exceptions/MEOSInternalErrorException.g.cs @@ -0,0 +1,15 @@ +#nullable enable + +using MEOS.NET.Errors; + +namespace MEOS.NET.Exceptions +{ + /// Unspecified internal error (MEOS_ERR_INTERNAL_ERROR). + [System.CodeDom.Compiler.GeneratedCode("MEOS.NET.ObjectGen", "0.1.0")] + public class MEOSInternalErrorException : MEOSException + { + internal MEOSInternalErrorException(int level, MEOSErrorCodes code, string message) + : base(level, code, message) + { } + } +} diff --git a/MEOS.NET/Exceptions/MEOSInternalTypeErrorException.cs b/MEOS.NET/Exceptions/MEOSInternalTypeErrorException.cs deleted file mode 100644 index 03f4520..0000000 --- a/MEOS.NET/Exceptions/MEOSInternalTypeErrorException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using MEOS.NET.Errors; - -namespace MEOS.NET.Exceptions -{ - public class MEOSInternalTypeErrorException : MEOSException - { - internal MEOSInternalTypeErrorException(int level, MEOSErrorCodes code, string message) - : base(level, code, message) - { } - } -} diff --git a/MEOS.NET/Exceptions/MEOSInternalTypeErrorException.g.cs b/MEOS.NET/Exceptions/MEOSInternalTypeErrorException.g.cs new file mode 100644 index 0000000..4b147c4 --- /dev/null +++ b/MEOS.NET/Exceptions/MEOSInternalTypeErrorException.g.cs @@ -0,0 +1,15 @@ +#nullable enable + +using MEOS.NET.Errors; + +namespace MEOS.NET.Exceptions +{ + /// Internal type error (MEOS_ERR_INTERNAL_TYPE_ERROR). + [System.CodeDom.Compiler.GeneratedCode("MEOS.NET.ObjectGen", "0.1.0")] + public class MEOSInternalTypeErrorException : MEOSException + { + internal MEOSInternalTypeErrorException(int level, MEOSErrorCodes code, string message) + : base(level, code, message) + { } + } +} diff --git a/MEOS.NET/Exceptions/MEOSInvalidArgException.g.cs b/MEOS.NET/Exceptions/MEOSInvalidArgException.g.cs new file mode 100644 index 0000000..5929afe --- /dev/null +++ b/MEOS.NET/Exceptions/MEOSInvalidArgException.g.cs @@ -0,0 +1,15 @@ +#nullable enable + +using MEOS.NET.Errors; + +namespace MEOS.NET.Exceptions +{ + /// Invalid argument (MEOS_ERR_INVALID_ARG). + [System.CodeDom.Compiler.GeneratedCode("MEOS.NET.ObjectGen", "0.1.0")] + public class MEOSInvalidArgException : MEOSException + { + internal MEOSInvalidArgException(int level, MEOSErrorCodes code, string message) + : base(level, code, message) + { } + } +} diff --git a/MEOS.NET/Exceptions/MEOSInvalidArgTypeException.g.cs b/MEOS.NET/Exceptions/MEOSInvalidArgTypeException.g.cs new file mode 100644 index 0000000..a36c306 --- /dev/null +++ b/MEOS.NET/Exceptions/MEOSInvalidArgTypeException.g.cs @@ -0,0 +1,15 @@ +#nullable enable + +using MEOS.NET.Errors; + +namespace MEOS.NET.Exceptions +{ + /// Invalid argument type (MEOS_ERR_INVALID_ARG_TYPE). + [System.CodeDom.Compiler.GeneratedCode("MEOS.NET.ObjectGen", "0.1.0")] + public class MEOSInvalidArgTypeException : MEOSException + { + internal MEOSInvalidArgTypeException(int level, MEOSErrorCodes code, string message) + : base(level, code, message) + { } + } +} diff --git a/MEOS.NET/Exceptions/MEOSInvalidArgValueException.g.cs b/MEOS.NET/Exceptions/MEOSInvalidArgValueException.g.cs new file mode 100644 index 0000000..8205f33 --- /dev/null +++ b/MEOS.NET/Exceptions/MEOSInvalidArgValueException.g.cs @@ -0,0 +1,15 @@ +#nullable enable + +using MEOS.NET.Errors; + +namespace MEOS.NET.Exceptions +{ + /// Invalid argument value (MEOS_ERR_INVALID_ARG_VALUE). + [System.CodeDom.Compiler.GeneratedCode("MEOS.NET.ObjectGen", "0.1.0")] + public class MEOSInvalidArgValueException : MEOSException + { + internal MEOSInvalidArgValueException(int level, MEOSErrorCodes code, string message) + : base(level, code, message) + { } + } +} diff --git a/MEOS.NET/Exceptions/MEOSInvalidArgumentException.cs b/MEOS.NET/Exceptions/MEOSInvalidArgumentException.cs deleted file mode 100644 index b87be29..0000000 --- a/MEOS.NET/Exceptions/MEOSInvalidArgumentException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using MEOS.NET.Errors; - -namespace MEOS.NET.Exceptions -{ - public class MEOSInvalidArgumentException : MEOSException - { - internal MEOSInvalidArgumentException(int level, MEOSErrorCodes code, string message) - : base(level, code, message) - { } - } -} diff --git a/MEOS.NET/Exceptions/MEOSInvalidArgumentTypeException.cs b/MEOS.NET/Exceptions/MEOSInvalidArgumentTypeException.cs deleted file mode 100644 index 03e1800..0000000 --- a/MEOS.NET/Exceptions/MEOSInvalidArgumentTypeException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using MEOS.NET.Errors; - -namespace MEOS.NET.Exceptions -{ - public class MEOSInvalidArgumentTypeException : MEOSException - { - internal MEOSInvalidArgumentTypeException(int level, MEOSErrorCodes code, string message) - : base(level, code, message) - { } - } -} diff --git a/MEOS.NET/Exceptions/MEOSInvalidArgumentValueException.cs b/MEOS.NET/Exceptions/MEOSInvalidArgumentValueException.cs deleted file mode 100644 index ccbcaa3..0000000 --- a/MEOS.NET/Exceptions/MEOSInvalidArgumentValueException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using MEOS.NET.Errors; - -namespace MEOS.NET.Exceptions -{ - public class MEOSInvalidArgumentValueException : MEOSException - { - internal MEOSInvalidArgumentValueException(int level, MEOSErrorCodes code, string message) - : base(level, code, message) - { } - } -} diff --git a/MEOS.NET/Exceptions/MEOSInvalidRegularExpressionException.g.cs b/MEOS.NET/Exceptions/MEOSInvalidRegularExpressionException.g.cs new file mode 100644 index 0000000..325522e --- /dev/null +++ b/MEOS.NET/Exceptions/MEOSInvalidRegularExpressionException.g.cs @@ -0,0 +1,15 @@ +#nullable enable + +using MEOS.NET.Errors; + +namespace MEOS.NET.Exceptions +{ + /// Regular expression error (MEOS_ERR_INVALID_REGULAR_EXPRESSION). + [System.CodeDom.Compiler.GeneratedCode("MEOS.NET.ObjectGen", "0.1.0")] + public class MEOSInvalidRegularExpressionException : MEOSException + { + internal MEOSInvalidRegularExpressionException(int level, MEOSErrorCodes code, string message) + : base(level, code, message) + { } + } +} diff --git a/MEOS.NET/Exceptions/MEOSMFJSONInputException.g.cs b/MEOS.NET/Exceptions/MEOSMFJSONInputException.g.cs new file mode 100644 index 0000000..6f49105 --- /dev/null +++ b/MEOS.NET/Exceptions/MEOSMFJSONInputException.g.cs @@ -0,0 +1,15 @@ +#nullable enable + +using MEOS.NET.Errors; + +namespace MEOS.NET.Exceptions +{ + /// MFJSON input error (MEOS_ERR_MFJSON_INPUT). + [System.CodeDom.Compiler.GeneratedCode("MEOS.NET.ObjectGen", "0.1.0")] + public class MEOSMFJSONInputException : MEOSException + { + internal MEOSMFJSONInputException(int level, MEOSErrorCodes code, string message) + : base(level, code, message) + { } + } +} diff --git a/MEOS.NET/Exceptions/MEOSMFJSONOutputException.g.cs b/MEOS.NET/Exceptions/MEOSMFJSONOutputException.g.cs new file mode 100644 index 0000000..1a5c44e --- /dev/null +++ b/MEOS.NET/Exceptions/MEOSMFJSONOutputException.g.cs @@ -0,0 +1,15 @@ +#nullable enable + +using MEOS.NET.Errors; + +namespace MEOS.NET.Exceptions +{ + /// MFJSON output error (MEOS_ERR_MFJSON_OUTPUT). + [System.CodeDom.Compiler.GeneratedCode("MEOS.NET.ObjectGen", "0.1.0")] + public class MEOSMFJSONOutputException : MEOSException + { + internal MEOSMFJSONOutputException(int level, MEOSErrorCodes code, string message) + : base(level, code, message) + { } + } +} diff --git a/MEOS.NET/Exceptions/MEOSMemoryAllocErrorException.g.cs b/MEOS.NET/Exceptions/MEOSMemoryAllocErrorException.g.cs new file mode 100644 index 0000000..6ddaa7e --- /dev/null +++ b/MEOS.NET/Exceptions/MEOSMemoryAllocErrorException.g.cs @@ -0,0 +1,15 @@ +#nullable enable + +using MEOS.NET.Errors; + +namespace MEOS.NET.Exceptions +{ + /// Internal malloc error (MEOS_ERR_MEMORY_ALLOC_ERROR). + [System.CodeDom.Compiler.GeneratedCode("MEOS.NET.ObjectGen", "0.1.0")] + public class MEOSMemoryAllocErrorException : MEOSException + { + internal MEOSMemoryAllocErrorException(int level, MEOSErrorCodes code, string message) + : base(level, code, message) + { } + } +} diff --git a/MEOS.NET/Exceptions/MEOSMemoryAllocationException.cs b/MEOS.NET/Exceptions/MEOSMemoryAllocationException.cs deleted file mode 100644 index 126bd36..0000000 --- a/MEOS.NET/Exceptions/MEOSMemoryAllocationException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using MEOS.NET.Errors; - -namespace MEOS.NET.Exceptions -{ - public class MEOSMemoryAllocationException : MEOSException - { - internal MEOSMemoryAllocationException(int level, MEOSErrorCodes code, string message) - : base(level, code, message) - { } - } -} diff --git a/MEOS.NET/Exceptions/MEOSNullResultException.g.cs b/MEOS.NET/Exceptions/MEOSNullResultException.g.cs new file mode 100644 index 0000000..62c5986 --- /dev/null +++ b/MEOS.NET/Exceptions/MEOSNullResultException.g.cs @@ -0,0 +1,15 @@ +#nullable enable + +using MEOS.NET.Errors; + +namespace MEOS.NET.Exceptions +{ + /// Operation returned null (MEOS_ERR_NULL_RESULT). + [System.CodeDom.Compiler.GeneratedCode("MEOS.NET.ObjectGen", "0.1.0")] + public class MEOSNullResultException : MEOSException + { + internal MEOSNullResultException(int level, MEOSErrorCodes code, string message) + : base(level, code, message) + { } + } +} diff --git a/MEOS.NET/Exceptions/MEOSOutOfMemoryException.g.cs b/MEOS.NET/Exceptions/MEOSOutOfMemoryException.g.cs new file mode 100644 index 0000000..f4a4d43 --- /dev/null +++ b/MEOS.NET/Exceptions/MEOSOutOfMemoryException.g.cs @@ -0,0 +1,15 @@ +#nullable enable + +using MEOS.NET.Errors; + +namespace MEOS.NET.Exceptions +{ + /// Out of memory error (MEOS_ERR_OUT_OF_MEMORY). + [System.CodeDom.Compiler.GeneratedCode("MEOS.NET.ObjectGen", "0.1.0")] + public class MEOSOutOfMemoryException : MEOSException + { + internal MEOSOutOfMemoryException(int level, MEOSErrorCodes code, string message) + : base(level, code, message) + { } + } +} diff --git a/MEOS.NET/Exceptions/MEOSSQLJSONErrorException.g.cs b/MEOS.NET/Exceptions/MEOSSQLJSONErrorException.g.cs new file mode 100644 index 0000000..a8792d1 --- /dev/null +++ b/MEOS.NET/Exceptions/MEOSSQLJSONErrorException.g.cs @@ -0,0 +1,15 @@ +#nullable enable + +using MEOS.NET.Errors; + +namespace MEOS.NET.Exceptions +{ + /// SQL JSON error (MEOS_ERR_SQL_JSON_ERROR). + [System.CodeDom.Compiler.GeneratedCode("MEOS.NET.ObjectGen", "0.1.0")] + public class MEOSSQLJSONErrorException : MEOSException + { + internal MEOSSQLJSONErrorException(int level, MEOSErrorCodes code, string message) + : base(level, code, message) + { } + } +} diff --git a/MEOS.NET/Exceptions/MEOSSyntaxErrorException.g.cs b/MEOS.NET/Exceptions/MEOSSyntaxErrorException.g.cs new file mode 100644 index 0000000..b58b45c --- /dev/null +++ b/MEOS.NET/Exceptions/MEOSSyntaxErrorException.g.cs @@ -0,0 +1,15 @@ +#nullable enable + +using MEOS.NET.Errors; + +namespace MEOS.NET.Exceptions +{ + /// Syntax error (MEOS_ERR_SYNTAX_ERROR). + [System.CodeDom.Compiler.GeneratedCode("MEOS.NET.ObjectGen", "0.1.0")] + public class MEOSSyntaxErrorException : MEOSException + { + internal MEOSSyntaxErrorException(int level, MEOSErrorCodes code, string message) + : base(level, code, message) + { } + } +} diff --git a/MEOS.NET/Exceptions/MEOSTextInputException.g.cs b/MEOS.NET/Exceptions/MEOSTextInputException.g.cs new file mode 100644 index 0000000..472e067 --- /dev/null +++ b/MEOS.NET/Exceptions/MEOSTextInputException.g.cs @@ -0,0 +1,15 @@ +#nullable enable + +using MEOS.NET.Errors; + +namespace MEOS.NET.Exceptions +{ + /// Text input error (MEOS_ERR_TEXT_INPUT). + [System.CodeDom.Compiler.GeneratedCode("MEOS.NET.ObjectGen", "0.1.0")] + public class MEOSTextInputException : MEOSException + { + internal MEOSTextInputException(int level, MEOSErrorCodes code, string message) + : base(level, code, message) + { } + } +} diff --git a/MEOS.NET/Exceptions/MEOSTextOutputException.g.cs b/MEOS.NET/Exceptions/MEOSTextOutputException.g.cs new file mode 100644 index 0000000..4390ff2 --- /dev/null +++ b/MEOS.NET/Exceptions/MEOSTextOutputException.g.cs @@ -0,0 +1,15 @@ +#nullable enable + +using MEOS.NET.Errors; + +namespace MEOS.NET.Exceptions +{ + /// Text output error (MEOS_ERR_TEXT_OUTPUT). + [System.CodeDom.Compiler.GeneratedCode("MEOS.NET.ObjectGen", "0.1.0")] + public class MEOSTextOutputException : MEOSException + { + internal MEOSTextOutputException(int level, MEOSErrorCodes code, string message) + : base(level, code, message) + { } + } +} diff --git a/MEOS.NET/Exceptions/MEOSUnspecifiedInternalException.cs b/MEOS.NET/Exceptions/MEOSUnspecifiedInternalException.cs deleted file mode 100644 index aa5f5c5..0000000 --- a/MEOS.NET/Exceptions/MEOSUnspecifiedInternalException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using MEOS.NET.Errors; - -namespace MEOS.NET.Exceptions -{ - public class MEOSUnspecifiedInternalException : MEOSException - { - internal MEOSUnspecifiedInternalException(int level, MEOSErrorCodes code, string message) - : base(level, code, message) - { } - } -} diff --git a/MEOS.NET/Exceptions/MEOSValueOutOfRangeException.cs b/MEOS.NET/Exceptions/MEOSValueOutOfRangeException.cs deleted file mode 100644 index a111958..0000000 --- a/MEOS.NET/Exceptions/MEOSValueOutOfRangeException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using MEOS.NET.Errors; - -namespace MEOS.NET.Exceptions -{ - public class MEOSValueOutOfRangeException : MEOSException - { - internal MEOSValueOutOfRangeException(int level, MEOSErrorCodes code, string message) - : base(level, code, message) - { } - } -} diff --git a/MEOS.NET/Exceptions/MEOSValueOutOfRangeException.g.cs b/MEOS.NET/Exceptions/MEOSValueOutOfRangeException.g.cs new file mode 100644 index 0000000..47d1054 --- /dev/null +++ b/MEOS.NET/Exceptions/MEOSValueOutOfRangeException.g.cs @@ -0,0 +1,15 @@ +#nullable enable + +using MEOS.NET.Errors; + +namespace MEOS.NET.Exceptions +{ + /// Internal out of range error (MEOS_ERR_VALUE_OUT_OF_RANGE). + [System.CodeDom.Compiler.GeneratedCode("MEOS.NET.ObjectGen", "0.1.0")] + public class MEOSValueOutOfRangeException : MEOSException + { + internal MEOSValueOutOfRangeException(int level, MEOSErrorCodes code, string message) + : base(level, code, message) + { } + } +} diff --git a/MEOS.NET/Exceptions/MEOSWKBInputException.g.cs b/MEOS.NET/Exceptions/MEOSWKBInputException.g.cs new file mode 100644 index 0000000..c8a82ed --- /dev/null +++ b/MEOS.NET/Exceptions/MEOSWKBInputException.g.cs @@ -0,0 +1,15 @@ +#nullable enable + +using MEOS.NET.Errors; + +namespace MEOS.NET.Exceptions +{ + /// WKB input error (MEOS_ERR_WKB_INPUT). + [System.CodeDom.Compiler.GeneratedCode("MEOS.NET.ObjectGen", "0.1.0")] + public class MEOSWKBInputException : MEOSException + { + internal MEOSWKBInputException(int level, MEOSErrorCodes code, string message) + : base(level, code, message) + { } + } +} diff --git a/MEOS.NET/Exceptions/MEOSWKBOutputException.g.cs b/MEOS.NET/Exceptions/MEOSWKBOutputException.g.cs new file mode 100644 index 0000000..2009c2b --- /dev/null +++ b/MEOS.NET/Exceptions/MEOSWKBOutputException.g.cs @@ -0,0 +1,15 @@ +#nullable enable + +using MEOS.NET.Errors; + +namespace MEOS.NET.Exceptions +{ + /// WKB output error (MEOS_ERR_WKB_OUTPUT). + [System.CodeDom.Compiler.GeneratedCode("MEOS.NET.ObjectGen", "0.1.0")] + public class MEOSWKBOutputException : MEOSException + { + internal MEOSWKBOutputException(int level, MEOSErrorCodes code, string message) + : base(level, code, message) + { } + } +} diff --git a/MEOS.NET/Types/Temporal/Temporal.cs b/MEOS.NET/Types/Temporal/Temporal.cs index 3925903..40ec1d9 100644 --- a/MEOS.NET/Types/Temporal/Temporal.cs +++ b/MEOS.NET/Types/Temporal/Temporal.cs @@ -128,9 +128,9 @@ public InterpolationType Interpolation() // temporal_interp names one of the interpolations MEOS defines, out of // its own static table, so the name is there for every temporal value. var interpolationStr = MEOSExposedFunctions.temporal_interp(this._ptr) - ?? throw new MEOSUnspecifiedInternalException( - (int)MEOSErrorCodes.UnspecifiedInternalError, - MEOSErrorCodes.UnspecifiedInternalError, + ?? throw new MEOSInternalErrorException( + (int)MEOSErrorCodes.InternalError, + MEOSErrorCodes.InternalError, "MEOS named no interpolation for this temporal value"); return EnumConverter.InterpolationTypeFromString(interpolationStr); } diff --git a/tools/objectgen.py b/tools/objectgen.py index 7fe5fe0..0500d54 100644 --- a/tools/objectgen.py +++ b/tools/objectgen.py @@ -34,6 +34,8 @@ GENERATOR_VERSION = "0.1.0" NAMESPACE = "MEOS.NET.Types.Generated" +ERROR_NAMESPACE = "MEOS.NET.Errors" +EXCEPTION_NAMESPACE = "MEOS.NET.Exceptions" # The C struct a class's instances are pointers to. Every other class resolves to # one of these through the model's own hierarchy, so this map holds only the roots @@ -66,6 +68,10 @@ "char *", "void", } +# Acronym runs the error names carry, kept upper-case so the C# spelling reads +# the way the catalog's own camelCase names do (`asMFJSON`). +ERROR_ACRONYMS = {"wkb", "mfjson", "geojson", "sql", "json"} + RESERVED = { "abstract", "as", "base", "bool", "break", "byte", "case", "catch", "char", "checked", "class", "const", "continue", "decimal", "default", "delegate", @@ -89,6 +95,15 @@ def pascal(oo_name: str) -> str: return oo_name[:1].upper() + oo_name[1:] +def error_member(code_name: str) -> str: + """The C# name of an errorCode constant: `MEOS_ERR_INVALID_ARG_VALUE` reads + `InvalidArgValue`, `MEOS_ERR_MFJSON_INPUT` reads `MFJSONInput`.""" + bare = code_name.removeprefix("MEOS_ERR_").removeprefix("MEOS_") + return "".join(part.upper() if part.lower() in ERROR_ACRONYMS + else part.capitalize() + for part in bare.lower().split("_")) + + def ident(name: str) -> str: return f"@{name}" if name in RESERVED else name @@ -457,6 +472,132 @@ def convert_file(self) -> str: }} ''' + def error_codes(self) -> list[dict]: + """The error taxonomy the model carries, verbatim from MEOS's own enum.""" + return self.m.om["errors"]["codes"] + + def error_codes_file(self) -> str: + lines = [ + "#nullable enable", + "", + f"namespace {ERROR_NAMESPACE}", + "{", + " /// Every code MEOS raises with, and what each one means.", + f' [System.CodeDom.Compiler.GeneratedCode("MEOS.NET.ObjectGen", "{GENERATOR_VERSION}")]', + " public enum MEOSErrorCodes", + " {", + ] + for code in self.error_codes(): + lines += [ + f" /// {code['meaning']} ({code['name']}).", + f" {error_member(code['name'])} = {code['value']},", + "", + ] + lines += [" }", "}", ""] + return "\n".join(lines) + + def exception_file(self, code: dict) -> str: + member = error_member(code["name"]) + return f'''#nullable enable + +using {ERROR_NAMESPACE}; + +namespace {EXCEPTION_NAMESPACE} +{{ + /// {code['meaning']} ({code['name']}). + [System.CodeDom.Compiler.GeneratedCode("MEOS.NET.ObjectGen", "{GENERATOR_VERSION}")] + public class MEOS{member}Exception : MEOSException + {{ + internal MEOS{member}Exception(int level, MEOSErrorCodes code, string message) + : base(level, code, message) + {{ }} + }} +}} +''' + + def exception_base_file(self) -> str: + return f'''#nullable enable + +using {ERROR_NAMESPACE}; + +namespace {EXCEPTION_NAMESPACE} +{{ + /// An error MEOS raised, with the code and level it raised it at. + [System.CodeDom.Compiler.GeneratedCode("MEOS.NET.ObjectGen", "{GENERATOR_VERSION}")] + public abstract class MEOSException : Exception + {{ + public int Level {{ get; init; }} + + public MEOSErrorCodes Code {{ get; init; }} + + internal MEOSException(int level, MEOSErrorCodes code, string message) + : base(message) + {{ + this.Level = level; + this.Code = code; + }} + }} +}} +''' + + def error_handling_file(self) -> str: + """The handler MEOS calls, and the check every wrapper makes after a call. + + MEOS reports an error through the handler and returns; the value it returns + then means nothing, so the wrapper raises what the handler recorded.""" + unknown = error_member(next( + c["name"] for c in self.error_codes() if c["value"] == 1)) + lines = [ + "#nullable enable", + "", + f"using {EXCEPTION_NAMESPACE};", + "", + f"namespace {ERROR_NAMESPACE}", + "{", + " /// Turns the error MEOS reports into the exception for its code.", + f' [System.CodeDom.Compiler.GeneratedCode("MEOS.NET.ObjectGen", "{GENERATOR_VERSION}")]', + " internal static class MEOSErrorHandling", + " {", + " private static MEOSException? pending;", + "", + " /// Raise what MEOS reported since the last check, if anything.", + " internal static void CheckError()", + " {", + " if (pending is null)", + " {", + " return;", + " }", + "", + " var raised = pending;", + " pending = null;", + " throw raised;", + " }", + "", + " /// The handler MEOS calls; it records, and CheckError raises.", + " internal static void InternalErrorHandler(int level, int errorCode, string message)", + " => pending = errorCode switch", + " {", + ] + for code in self.error_codes(): + member = error_member(code["name"]) + if code["value"] == 0: + lines.append(f" {code['value']} => null, // {code['name']}") + else: + lines.append( + f" {code['value']} => new MEOS{member}Exception(" + f"level, MEOSErrorCodes.{member}, message),") + lines += [ + " // A code this binding does not name is still an error MEOS", + " // raised, so it reaches the caller rather than being dropped.", + f" _ => new MEOS{unknown}Exception(", + f" level, MEOSErrorCodes.{unknown}, message),", + " };", + " }", + "}", + "", + ] + return "\n".join(lines) + def factory_file(self) -> str: """The runtime factory: a MEOS value carries its own type in its header, so a pointer is wrapped in the exact class the model gives that type. Every @@ -595,6 +736,21 @@ def run(self, out_dir: Path) -> None: (out_dir / f"{cls}.g.cs").write_text(self.emit_class(cls)) (out_dir / "MEOSFactory.g.cs").write_text(self.factory_file()) + def run_errors(self, errors_dir: Path, exceptions_dir: Path) -> None: + for directory in (errors_dir, exceptions_dir): + if directory.exists(): + shutil.rmtree(directory) + directory.mkdir(parents=True) + (errors_dir / "MEOSErrorCodes.g.cs").write_text(self.error_codes_file()) + (errors_dir / "MEOSErrorHandling.g.cs").write_text(self.error_handling_file()) + (exceptions_dir / "MEOSException.g.cs").write_text(self.exception_base_file()) + for code in self.error_codes(): + if code["value"] == 0: + continue + member = error_member(code["name"]) + (exceptions_dir / f"MEOS{member}Exception.g.cs").write_text( + self.exception_file(code)) + def main() -> int: ap = argparse.ArgumentParser(description=__doc__) @@ -613,6 +769,8 @@ def main() -> int: gen = Generator(model) repo_root = Path(__file__).resolve().parent.parent gen.run(repo_root / "MEOS.NET" / "Types" / "Generated") + gen.run_errors(repo_root / "MEOS.NET" / "Errors", + repo_root / "MEOS.NET" / "Exceptions") classes = model.classes() total_deferred = sum(len(v) for v in gen.deferred.values())