Skip to content

Commit feb612b

Browse files
authored
Add Time::Error (#14743)
1 parent 7d8e243 commit feb612b

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/time.cr

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,11 @@ require "crystal/system/time"
212212
# elapsed_time # => 20.milliseconds (approximately)
213213
# ```
214214
struct Time
215-
class FloatingTimeConversionError < Exception
215+
# Raised when an error occurs while performing a `Time` based operation.
216+
class Error < Exception
217+
end
218+
219+
class FloatingTimeConversionError < Error
216220
end
217221

218222
include Comparable(Time)

src/time/location.cr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class Time::Location
5151
# the time zone database.
5252
#
5353
# See `Time::Location.load` for details.
54-
class InvalidLocationNameError < Exception
54+
class InvalidLocationNameError < Time::Error
5555
getter name, source
5656

5757
def initialize(@name : String, @source : String? = nil)
@@ -63,7 +63,7 @@ class Time::Location
6363

6464
# `InvalidTimezoneOffsetError` is raised if `Time::Location::Zone.new`
6565
# receives an invalid time zone offset.
66-
class InvalidTimezoneOffsetError < Exception
66+
class InvalidTimezoneOffsetError < Time::Error
6767
def initialize(offset : Int)
6868
super "Invalid time zone offset: #{offset}"
6969
end

src/time/location/loader.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class Time::Location
55
# time zone data.
66
#
77
# Details on the exact cause can be found in the error message.
8-
class InvalidTZDataError < Exception
8+
class InvalidTZDataError < Time::Error
99
def self.initialize(message : String? = "Malformed time zone information", cause : Exception? = nil)
1010
super(message, cause)
1111
end

0 commit comments

Comments
 (0)