jfcameron / gdk-graphics

3D Rendering using OpenGLES 2.0/WebGL1.0. Platforms: Linux, Windows, Mac, x86 64bit, arm64, wasm
MIT License
1 stars 1 forks source link

exception design: separate presentation from meaning, etc. #64

Open jfcameron opened 3 years ago

jfcameron commented 3 years ago

Problem: i have made an effort to throw exceptions where appropriate, however I keep using stl types and conveying library specific information via the what string. This ties exception handling to string parsing and presentation to the english language.

Thoughts: Need to come up with an exception type policy. This project should provide nonstandard exception types (to differentiate exceptions thrown by this lib vs others), and those types should convey useful information. One type is useful, because it allows users to differentiate exceptions thrown by this lib vs any other lib. A single type with specifics about the throw in the what string does not get away from the problem of presentation vs cause.

Possible solution: A single exception type that contains a lib defined enum member could be the best solution. this would provide a lib specific type, so users could specify a catch block that only listens to exceptions thrown from this library, and the lib provided enum would be a mechanism to further decorate the exception (out of bounds, out of memory, invalid vertex format, ...) in a language agnostic way and without the number of exception types exploding to something unmanagable