Skip to content

Commit

Permalink
feat: type-safe creation failure exceptions are now data-classes
Browse files Browse the repository at this point in the history
  • Loading branch information
y9vad9 committed Jun 11, 2023
1 parent 182c3d6 commit 7fa2875
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ public sealed class CreationFailure(message: String) : TimeMatesException(messag
/**
* Represents a creation failure due to a size range constraint.
*/
public class SizeRangeFailure(public val range: IntRange) : CreationFailure("Constraint failure: size must be in range of $range")
public data class SizeRangeFailure(public val range: IntRange) : CreationFailure("Constraint failure: size must be in range of $range")

/**
* Represents a creation failure due to an exact size constraint.
*/
public class SizeExactFailure(public val size: Int) : CreationFailure("Constraint failure: size must be exactly $size")
public data class SizeExactFailure(public val size: Int) : CreationFailure("Constraint failure: size must be exactly $size")

/**
* Represents a creation failure due to a minimum value constraint.
*/
public class MinValueFailure(public val size: Int) : CreationFailure("Constraint failure: minimal value is $size")
public data class MinValueFailure(public val size: Int) : CreationFailure("Constraint failure: minimal value is $size")

/**
* Represents a creation failure due to a blank value constraint.
Expand All @@ -36,7 +36,7 @@ public sealed class CreationFailure(message: String) : TimeMatesException(messag
/**
* Represents a creation failure due to a pattern constraint.
*/
public class PatternFailure(public val regex: Regex) : CreationFailure("Constraint failure: input should match $regex")
public data class PatternFailure(public val regex: Regex) : CreationFailure("Constraint failure: input should match $regex")

public companion object {
/**
Expand Down

0 comments on commit 7fa2875

Please sign in to comment.