In the example about the red button, I was talking about some external factor 
that most of the code (especially other people's code) doesn't know about and 
enum ErrorCode. For example, vulkan has a VkResult 
<https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkResult.html>
 for example VK_ERROR_TOO_MANY_OBJECTS, it has ErrorCode FullError, but the 
party catching the exception can catch FullError, and usually it is memory 
specific on the process, but in vulkan this memory is on the gpu (and will 
probably have to be freed on the gpu). A regular Full Error does not take this 
specificity into account, so it would be nice to register your own GpuFullError 
(by the way, vulkan api has a lot of errors that don't really fit into the 
regular ErrorCode). Besides the same GpuFullError is useful because of raises 
pragma, for example I want to forbid the possibility to use functions that can 
overflow the number of objects on gpu.

As for adding Custom Error Codes via raises, I think it should be. However, I 
think that wherever there will be Error Codes documentation it should be 
mentioned that custom codes should be used only if it is really necessary 
(which should be very rare). Since otherwise it will get in the way.

Reply via email to