Question

Le D de la documentation semble être un peu brouillon, et je ne suis pas en mesure de trouver cette information n'importe où sur le site officiel.Je suis besoin de quelques communes de types d'exceptions (par ex.NotFiniteNumberException, FileIOException, des types comme ça), est-ce que exister dans les bibliothèques de base, ou devrais-je rouler moi-même?

Était-ce utile?

La solution

Certains d'entre eux existent, certains d'entre eux ne le font pas.La meilleure stratégie pour les trouver est tout simplement faire une recherche globale look pour le texte : Exception dans le D exécution (et Phobos), et de voir ce que tout le préexistants sont des exceptions.

Le plus probable, cependant, vous aurez à rouler sur au moins une partie de votre propre.

Ce que j'ai trouvé par le biais de cette recherche étaient les suivants:

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

(Bien sûr, si il y a des exceptions qui héritent des classes autres que les Exception, ou si l'espacement était bizarre, alors qu'ils ne sont pas sur cette liste.)

Autres conseils

La hiérarchie d'exception a été confie à Tango et un ensemble général est disponible chez Tango.core.Exception.

Plus votre exception est particulièrement spécialisée, les moins susceptibles de le trouver là-bas, mais l'intention était que toutes les exceptions soient logiques comme sous-classes aux exceptions existantes.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top