Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

typed exception X::Hash::Store::OddNumber #59

Merged
merged 2 commits into from

3 participants

@Siddhant

No description provided.

@moritz moritz merged commit 83b15cd into from
@oetiker oetiker commented on the diff
src/core/Exceptions.pm
@@ -325,3 +325,7 @@ my class X::Routine::Unwrap is Exception {
my class X::Constructor::Positional is Exception {
method message() { "Default constructor only takes named arguments" }
}
+
@oetiker
oetiker added a note

Moritz, just read your blog post. Cool.

Question: what is the idea behind having all exception classes declared in a central file and not locally?

cheers
tobi

Oetiker,

The advantage of having exception classes declared centrally is that it's easier to find them all and perhaps thus helps in easy localizations (translations).

@oetiker
oetiker added a note

the ease of grabbing strings for localization from source seems seems to be an odd reason for moving away from the well proven approach of keeping things together that work together ... eg documentation and code (see POD) ... so keeping all the exceptions in a separate tree seems odd, especially when I think of adding new exceptions for my own classes, or would that work differently ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 28, 2012
  1. @Siddhant
  2. @Siddhant
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 1 deletion.
  1. +4 −0 src/core/Exceptions.pm
  2. +3 −1 src/core/Hash.pm
View
4 src/core/Exceptions.pm
@@ -325,3 +325,7 @@ my class X::Routine::Unwrap is Exception {
my class X::Constructor::Positional is Exception {
method message() { "Default constructor only takes named arguments" }
}
+
@oetiker
oetiker added a note

Moritz, just read your blog post. Cool.

Question: what is the idea behind having all exception classes declared in a central file and not locally?

cheers
tobi

Oetiker,

The advantage of having exception classes declared centrally is that it's easier to find them all and perhaps thus helps in easy localizations (translations).

@oetiker
oetiker added a note

the ease of grabbing strings for localization from source seems seems to be an odd reason for moving away from the well proven approach of keeping things together that work together ... eg documentation and code (see POD) ... so keeping all the exceptions in a separate tree seems odd, especially when I think of adding new exceptions for my own classes, or would that work differently ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+my class X::Hash::Store::OddNumber is Exception {
+ method message() { "Odd number of elements found where hash expected" }
+}
View
4 src/core/Hash.pm
@@ -1,3 +1,5 @@
+my class X::Hash::Store::OddNumber { ... }
+
my class Hash {
# Has attributes and parent EnumMap declared in BOOTSTRAP
@@ -44,7 +46,7 @@ my class Hash {
}
elsif $items { self.STORE_AT_KEY($x.Str, $items.shift) }
else {
- die 'Odd number of elements found where hash expected'
+ die(X::Hash::Store::OddNumber.new())
}
}
self
Something went wrong with that request. Please try again.