/* * Exceptions defined using this template in errors.hpp * * This template defines the data in the sprawl::ExceptionId enum, the associated string output for enum value, and an exception class that derives from * the class generated for another enum value. It also provides a typedef for each value to make it easier for users to handle the exceptions. */ // Base Class Specific Error Error String Typedef // SPRAWL_EXCEPTION( GENERAL_EXCEPTION, UNIMPLEMENTED_VIRTUAL_METHOD, "The method called is not implemented on this object", UnimplementedVirtualMethod ) // Base Class Specific Error Error String Typedef // SPRAWL_EXCEPTION( GENERAL_EXCEPTION, SERIALIZATION_ERROR, "Serialization Error", SerializationError ) SPRAWL_EXCEPTION( SERIALIZATION_ERROR, INVALID_DATA, "Invalid input data", InvalidData ) SPRAWL_EXCEPTION( SERIALIZATION_ERROR, SERIALIZATION_OVERFLOW, "Serialization overflow", SerializationOverflow ) // Base Class Specific Error Error String Typedef // SPRAWL_EXCEPTION( SERIALIZATION_ERROR, JSON_ERROR, "JSON Error", JsonError ) SPRAWL_EXCEPTION( JSON_ERROR, JSON_TYPE_MISMATCH, "Requested field does not match requested type", JsonTypeMismatch ) SPRAWL_EXCEPTION( JSON_ERROR, INVALID_JSON_DATA, "Input data is not valid JSON", InvalidJsonData ) // Base Class Specific Error Error String Typedef // SPRAWL_EXCEPTION( GENERAL_EXCEPTION, COROUTINE_EXCEPTION, "Coroutine Error", CoroutineError ) SPRAWL_EXCEPTION( COROUTINE_EXCEPTION, INVALID_COROUTINE_TYPE, "Yield/Receive called on coroutine whose type did" " not match the expected type.", InvalidCoroutineType ) SPRAWL_EXCEPTION( COROUTINE_EXCEPTION, INVALID_SEND_TYPE, "Yield/Receive called on coroutine whose SendType" " did not match the passed type in size.", InvalidSendType ) SPRAWL_EXCEPTION( COROUTINE_EXCEPTION, INVALID_YIELD_TYPE, "Yield/Receive called on coroutine whose YieldType" " did not match the passed type in size.", InvalidYieldType ) // Base Class Specific Error Error String Typedef // SPRAWL_EXCEPTION( GENERAL_EXCEPTION, CONTAINER_EXCEPTION, "Container Error", ContainerError ) SPRAWL_EXCEPTION( CONTAINER_EXCEPTION, OUT_OF_RANGE, "Attempted to retrieve a value outside the allocated" " range of the container.", OutOfRangeError )
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 23398 | ququlala | "Forking branch Mainline of shadauxcat-libsprawl to ququlala-libsprawl." | ||
//guest/ShadauxCat/Sprawl/Mainline/common/exceptions.hpp | |||||
#2 | 16768 | ShadauxCat |
Improvements to error handling in builds with exceptions disabled: - In debug builds or with SPRAWL_ERRORSTATE_STRICT enabled, ErrorState will output a message to stderr and terminate if Get() is called when an error flag is set. (In release buils or with SPRAWL_ERRORSTATE_PERMISSIVE defined, Get() will return junk memory in this case.) - In debug builds or with SPRAWL_ERRORSTATE_STRICT enabled, ErrorState will output a message to stderr and terminate if its destructor is called without checking the errorstate if an error is present (equivalent to an exception terminating the application if no catch() block is present for it). - On linux builds and when running "Analyze" through visual studio, a warning will be issued if any function returning ErrorState has its return value ignored. (This only applies to builds with exceptions not enabled; when exceptions are enabled no warning is issued) - Many functions that could return ErrorState were having their return values silently ignored in internal sprawl code so the user would not find out about errors if exceptions are disabled; now anything in sprawl code that calls a function returning ErrorState will either handle the error, or (in most cases) surface it back up to the user. - As a positive side-effect of the warnings for ignoring ErrorState, several constructors that were capable of throwing exceptions are no longer capable of doing so. #review-16769 |
||
#1 | 16380 | ShadauxCat |
Missed a header, also corrected missing newline in exceptions.hpp, also corrected exceptions.hpp being exceptions.h. #review-16381 |
||
//guest/ShadauxCat/Sprawl/Mainline/common/exceptions.h | |||||
#1 | 16378 | ShadauxCat |
New exception framework, phase one. Added new class, ErrorState, for handling errors when exceptions are disabled. When exceptions are enabled, ErrorState<T> is an alias for T. When they're disabled, ErrorState<T> additionally encodes an error code, and will have junk data (and probably a crash) if an error is returned and not checked before the data is used. ErrorState<T> is implicitly convertible to and from T, so applications that don't care about errors can code like they don't exist... Phase two will involve overloading operators on ErrorState so that things that return ErrorState can still function as much as possible like they do when exceptions are enabled. #review-16379 |