Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

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

Merged
merged 2 commits into from about 2 years ago

3 participants

Siddhant Saraf Tobias Oetiker Moritz Lenz
Siddhant Saraf

No description provided.

Moritz Lenz moritz merged commit 83b15cd into from February 28, 2012
Moritz Lenz moritz closed this February 28, 2012
Tobias Oetiker oetiker commented on the diff February 29, 2012
src/core/Exceptions.pm
@@ -325,3 +325,7 @@ my class X::Routine::Unwrap is Exception {
325 325
 my class X::Constructor::Positional is Exception {
326 326
     method message() { "Default constructor only takes named arguments" }
327 327
 }
  328
+
3
Tobias Oetiker
oetiker added a note February 29, 2012

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

Siddhant Saraf
Siddhant added a note June 29, 2012

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).

Tobias Oetiker
oetiker added a note July 02, 2012

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
This page is out of date. Refresh to see the latest.
4  src/core/Exceptions.pm
@@ -325,3 +325,7 @@ my class X::Routine::Unwrap is Exception {
325 325
 my class X::Constructor::Positional is Exception {
326 326
     method message() { "Default constructor only takes named arguments" }
327 327
 }
  328
+
  329
+my class X::Hash::Store::OddNumber is Exception {
  330
+    method message() { "Odd number of elements found where hash expected" }
  331
+}
4  src/core/Hash.pm
... ...
@@ -1,3 +1,5 @@
  1
+my class X::Hash::Store::OddNumber { ... }
  2
+
1 3
 my class Hash {
2 4
     # Has attributes and parent EnumMap declared in BOOTSTRAP
3 5
 
@@ -44,7 +46,7 @@ my class Hash {
44 46
             }
45 47
             elsif $items { self.STORE_AT_KEY($x.Str, $items.shift) }
46 48
             else {
47  
-                die 'Odd number of elements found where hash expected'
  49
+                die(X::Hash::Store::OddNumber.new())
48 50
             }
49 51
         }
50 52
         self
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.