Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do Phobos (and/or Tango) have a set of predefined exception types?

The D documentation seems to be a bit messy, and I'm not able to find this information anywhere on the official site. I'm needing some common exception types (e.g. NotFiniteNumberException, FileIOException, types like that), do these exist in the core libraries, or would I have to roll these myself?

like image 307
Mark LeMoine Avatar asked May 20 '11 08:05

Mark LeMoine


2 Answers

Some of them exist, some of them don't. The best strategy to find them is to just do a global search look for the text : Exception in the D runtime (and Phobos), and seeing what all the preexisting exceptions are.

Most likely, though, you'll have to roll out at least some of your own.

What I found through this search were the following:

druntime\src\core\demangle.d(72):static class ParseException : Exception
druntime\src\core\demangle.d(81):static class OverflowException : Exception
druntime\src\core\exception.d(297):     class UnicodeException : Exception
druntime\src\core\thread.d(34):         class ThreadException : Exception
druntime\src\core\thread.d(51):         class FiberException : Exception
druntime\src\core\time.d(2703):         class TimeException : Exception
druntime\src\core\sync\exception.d(21): class SyncException : Exception
phobos\std\boxer.d(511):                class UnboxException : Exception
phobos\std\concurrency.d(198):          class MessageMismatch : Exception
phobos\std\concurrency.d(210):          class OwnerTerminated : Exception
phobos\std\concurrency.d(225):          class LinkTerminated : Exception
phobos\std\concurrency.d(240):          class PriorityMessageException: Exception
phobos\std\concurrency.d(255):          class MailboxFull : Exception
phobos\std\conv.d(33):                  class ConvException : Exception
phobos\std\demangle.d(26):      private class MangleException : Exception
phobos\std\encoding.d(2056):            class EncodingException : Exception
phobos\std\exception.d(792):            class ErrnoException : Exception
phobos\std\file.d(183):                 class FileException : Exception
phobos\std\json.d(418):                 class JSONException : Exception
phobos\std\regexp.d(161):               class RegExpException : Exception
phobos\std\socket.d(121):               class SocketException: Exception
phobos\std\socket.d(455):               class HostException: Exception
phobos\std\socket.d(670):               class AddressException: Exception
phobos\std\stdio.d(2111):               class StdioException : Exception
phobos\std\stream.d(44):                class StreamException: Exception
phobos\std\utf.d(45):                   class UtfException : Exception
phobos\std\variant.d(1153):      static class VariantException : Exception
phobos\std\xml.d(2726):                 class XMLException : Exception
phobos\std\zip.d(44):                   class ZipException : Exception
phobos\std\zlib.d(42):                  class ZlibException : Exception
phobos\std\windows\registry.d(75):      class Win32Exception : Exception

(Of course, if there are exceptions that inherit from classes other than Exception, or if there spacing was weird, then they're not on this list.)

like image 153
user541686 Avatar answered Oct 01 '22 10:10

user541686


The exception hierarchy was given quite some thought in Tango, and a general set is available from tango.core.Exception.

The more specialized your exception is, the less likely are you to find it there, but the intention was that all exceptions should make sense as subclasses to the existing exceptions.

like image 29
larsivi Avatar answered Oct 01 '22 11:10

larsivi