Error

public enum Error : Swift.Error
extension Error: LocalizedError

An enum representing any error that could be thrown during the use of DiceKit.

  • illegalNumberOfSides: A number of sides was passed that wasn’t allowed.
  • emptyString: An empty string was passed to a string parser that doesn’t accept empty strings.
  • nonNumericString: A string was passed with nonnumeric characters that weren’t expected.
  • illegalString: An illegal string was passed.
  • divisionByZero: Zero was passed to something that would have divided by it.
  • emptyDictionary: An empty dictionary was passed to something that needs a non-empty dictionary.
  • negativeArgument: An argument passed was negative, and only positive ones are allowed.
  • chanceOverOne: The chance of something happening was over 1, an impossibility.

Since

0.16.0

  • A number of sides was passed that wasn’t allowed.

    Declaration

    Swift

    case illegalNumberOfSides(attempt: Int)

    Parameters

    attempt

    The number of sides that was passed.

  • An empty string was passed to a string parser that doesn’t accept empty strings.

    Declaration

    Swift

    case emptyString
  • A string was passed with nonnumeric characters that weren’t expected.

    Declaration

    Swift

    case nonNumericString
  • An illegal string was passed.

    Generally, one of the other string-related errors will be thrown. This error will only be thrown if the others don’t apply.

    Declaration

    Swift

    case illegalString(string: String)

    Parameters

    string

    The string that was passed.

  • Zero was passed to something that would have divided by it.

    Declaration

    Swift

    case divisionByZero
  • An empty dictionary was passed to something that needs a non-empty dictionary.

    Declaration

    Swift

    case emptyDictionary
  • Arguments were passed that resulted in something being negative that needed to be positive. This doesn’t necessarily mean that the arguments passed in this case were negative, and it is possible to pass some negative arguments, as long as they cancel each other out. All this error means is that the result of a computation would have been negative.

    Declaration

    Swift

    case negativeArgument
  • The chance of something happening was over 1, an impossibility.

    This error was most likely thrown when creating a Chance instance. However, a Chances object can have Chances that sum to over 1.

    Declaration

    Swift

    case chanceOverOne
  • Declaration

    Swift

    public var errorDescription: String? { get }