Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Topic/structured exceptions #37

Closed
wants to merge 2,251 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
2251 commits
Select commit Hold shift + click to select a range
dd39530
fixed indentation
upasana-me Sep 14, 2013
774ea8c
Replaced throw_error with throw_exception
upasana-me Sep 14, 2013
52c6828
Wrote tests for HandOptimizedTypeConstraintIsNotCodeRef
upasana-me Sep 14, 2013
877c613
Wrote HandOptimizedTypeConstraintIsNotCodeRef
upasana-me Sep 14, 2013
db6d81f
Deleted SingleParamsToNewMustBeHRef & IncompatibleMetaclassOfSuperclass
upasana-me Sep 14, 2013
fed2649
removed whitespace
upasana-me Sep 14, 2013
0685ca0
annotated tests for documentation
upasana-me Sep 14, 2013
c51c623
Wrote AttributeNamesDoNotMatch & NeitherAttributeNorAttributeNameIsGiven
upasana-me Sep 14, 2013
8bc5d76
Wrote tests for Moose::Meta::Method::Accessor::Native::grep
upasana-me Sep 14, 2013
ef0ccde
Wrote tests for exception LazyAttributeNeedsADefault
upasana-me Sep 14, 2013
8bd2c50
Wrote role for attribute_name
upasana-me Sep 14, 2013
a2388f8
replaced _inline_throw_error with _inline_throw_exception
upasana-me Sep 14, 2013
5fffd44
wrote tests for AttributeIsRequired
upasana-me Sep 14, 2013
68f6bf5
Wrote comment for not converting error to structured exception
upasana-me Sep 15, 2013
f79ec28
Removed whitespace
upasana-me Sep 15, 2013
6ac1c88
changed exception name & used Moose::Exception::Role::Class
upasana-me Sep 15, 2013
1434ecc
Deleted MustSupplyAnArrayRefAsCurriedArguments
upasana-me Sep 15, 2013
b29cb21
replaced confess with throw_exception
upasana-me Sep 15, 2013
493e454
Corrected exception's name
upasana-me Sep 15, 2013
d93eb72
Wrote tests for MustSupplyArrayRefAsCurriedArguments
upasana-me Sep 15, 2013
90ba645
corrected exception name
upasana-me Sep 15, 2013
8b0c8a8
corrected exception name
upasana-me Sep 15, 2013
1b894d5
fixed indentation
upasana-me Sep 15, 2013
ec07654
improved delegation methods
upasana-me Sep 15, 2013
386e691
made changes to tests of OverrideConflictInSummation
upasana-me Sep 15, 2013
ad88cd2
no need to handle hand optimized typeconstraint, it's removed now
upasana-me Sep 15, 2013
b717e72
removed tests for hand-optimized typeconstraint exception
upasana-me Sep 15, 2013
1bf9d13
replaced ref with blessed
upasana-me Sep 15, 2013
d336dc8
removed 'An' from the exception name
upasana-me Sep 15, 2013
b8f7781
removed article from exception name
upasana-me Sep 15, 2013
a47ba13
added comment for intention syntax error
upasana-me Sep 15, 2013
ee8bed8
fixed indentation
upasana-me Sep 15, 2013
e496ebe
removed redundant delegation methods
upasana-me Sep 15, 2013
7857486
Wrote EitherAttributeOrAttributeName
upasana-me Sep 15, 2013
5fe8976
Used EitherAttributeOrAttributeName role
upasana-me Sep 15, 2013
7767079
replaced confess with throw_exception
upasana-me Sep 15, 2013
94f821f
Wrote tests for CannotAssignValueToReadOnlyAccessor
upasana-me Sep 15, 2013
baa4b52
used EitherAttributeOrAttributeName role
upasana-me Sep 15, 2013
7489d96
used IncompatibleMetaclassOfSuperclass
upasana-me Sep 18, 2013
1771d78
changed tests for IncompatibleMetaclassOfSuperclass
upasana-me Sep 18, 2013
899ffdf
Wrote IncompatibleMetaclassOfSuperclass
upasana-me Sep 18, 2013
22f120c
replaced confess with throw_exception
upasana-me Sep 18, 2013
03b9107
Wrote metaclass incompatibility exceptions for Class::MOP::Class
upasana-me Sep 18, 2013
a349e59
Wrote tests for metaclass compatibility exceptions of Class::MOP::Class
upasana-me Sep 18, 2013
a2e4dd2
replaced confess with throw_exception & minor modification in _anon_c…
upasana-me Sep 18, 2013
d741080
Wrote exception PackagesAndModuleAreNotCachable
upasana-me Sep 18, 2013
ce4a505
Wrote tests for exception PackagesAndModuleAreNotCachable
upasana-me Sep 18, 2013
0f247ee
replaced confess with throw_exception & minor modification in _anon_c…
upasana-me Sep 18, 2013
2338e43
Wrote tests for exception PackagesAndModuleAreNotCachable
upasana-me Sep 18, 2013
5b74cac
Using role EitherAttributeOrAttributeName,so removed the redundant code
upasana-me Sep 18, 2013
e182f8f
replaced die & throw_error with throw_exception
upasana-me Sep 18, 2013
531ee9a
Wrote exceptions for Moose::Exporter
upasana-me Sep 18, 2013
c52cbc6
wrote tests for exceptions in Moose::Exporter
upasana-me Sep 18, 2013
60a8a84
replaced throw_error with throw_exception
upasana-me Sep 18, 2013
356c86a
Wrote tests for UnableToRecognizeDelegateMetaclass
upasana-me Sep 18, 2013
a9530bd
wrote UnableToRecognizeDelegateMetaclass
upasana-me Sep 18, 2013
4f6b0bd
replaced confess with throw_exception
upasana-me Sep 18, 2013
83a3981
replaced throw_error with throw_exception
upasana-me Sep 18, 2013
613c8be
wrote tests for CouldNotParseType
upasana-me Sep 18, 2013
2bc377c
wrote CouldNotParseType
upasana-me Sep 18, 2013
2ced5c3
Replaced throw_error with confess(not a structured exception)
upasana-me Sep 18, 2013
547a371
removed trailing whitespace
upasana-me Sep 18, 2013
e4ead37
Wrote documentation generator for documenting exception classes
upasana-me Sep 18, 2013
97b8c09
replaced throw_error with confess (not a structured exception)
upasana-me Sep 18, 2013
65dd883
replaced throw_error with confess (not a structured exception)
upasana-me Sep 20, 2013
a1447ec
Removed extra line
upasana-me Sep 21, 2013
833c02f
renamed package_or_module to is_module
upasana-me Sep 21, 2013
83f3e8b
Renamed package_or_module to is_module & made it Bool
upasana-me Sep 21, 2013
246691e
Removed redundant code (moved it in the exception)
upasana-me Sep 21, 2013
b54ce8d
Renamed package_or_module to is_module
upasana-me Sep 21, 2013
523f7e6
removed whitespace
upasana-me Sep 22, 2013
de70059
replaced throw_error with throw_exception
upasana-me Sep 23, 2013
b88dbe4
Wrote exception CouldNotEvalCreateWriter
upasana-me Sep 23, 2013
5966fdb
Changed type of error, error isa Str|Moose::Exception
upasana-me Sep 23, 2013
ce3493d
Wrote tests for CouldNotCreateWriter
upasana-me Sep 23, 2013
8673ead
Removed data which I added by mistake
upasana-me Sep 23, 2013
f304a3a
deleted moose-meta-method-accessor.t
upasana-me Sep 23, 2013
7055414
Wrote tests for CouldNotCreateWriter
upasana-me Sep 23, 2013
53c9e42
Replaced confess with throw_exception
upasana-me Sep 23, 2013
d03d59f
Wrote tests for CouldNotEvalConstructor
upasana-me Sep 23, 2013
a677c09
Wrote exception CouldNotEvalConstructor
upasana-me Sep 23, 2013
78a81d3
removed reftype while merging conflicts, so added refype
upasana-me Sep 24, 2013
52e05ba
get rid of warning due to undefined {body}
upasana-me Sep 24, 2013
e2b6b99
get rid of deprecated hand-optimized type constraint
upasana-me Sep 24, 2013
45f3956
load Class::MOP at runtime,to prevent circular dependency
upasana-me Sep 24, 2013
c1708d1
lost this while resolving merge conflicts
upasana-me Sep 24, 2013
75824a2
Pass ARRAY ref to enum
upasana-me Sep 24, 2013
0f65a5b
Pass ARRAY ref to enum
upasana-me Sep 24, 2013
f2ad932
This exception has been replaced by MustPassEvenNumberOfAttributeOptions
upasana-me Sep 25, 2013
8f40a59
replaced InvalidHasProvided by MustPassEvenNumberOfAttributeOptions
upasana-me Sep 25, 2013
a7d1146
replaced throw_error with throw_exception
upasana-me Sep 25, 2013
c6e1da9
removed tests for InvalidHasProvided
upasana-me Sep 25, 2013
7a5c0ec
Wrote tests for exceptions in Moose::Meta::Attribute
upasana-me Sep 25, 2013
de4ff62
Wrote CannotCoerceAttributeWhichHasNoCoercion for Moose::Meta::Attribute
upasana-me Sep 25, 2013
eb0b629
Corrected exception message
upasana-me Sep 25, 2013
41f9ced
replaced throw_error with throw_exception
upasana-me Sep 25, 2013
ca2df4a
Wrote tests for exception in Moose::Util
upasana-me Sep 25, 2013
07cd106
Wrote exception CannotLocatePackageInINC for Moose::Util
upasana-me Sep 25, 2013
e7a1251
Got rid of load_class (introduced while resolving merge conflicts)
upasana-me Sep 25, 2013
8118757
shortened method_constructor_object to constructor_method
upasana-me Sep 29, 2013
8159dad
Wrote a comment for intention syntax error
upasana-me Sep 29, 2013
755d51a
attribute_name can be fetched from attribute,so no need to pass attri…
upasana-me Sep 29, 2013
42d9e0f
Added one more attribute(class) to ExtendsMissingArgs
upasana-me Oct 1, 2013
b5cd17c
written test for extends
upasana-me Jun 15, 2013
597682f
Wrote test case for Moose::Exception::ExtendsMissingArgs object
upasana-me Jun 19, 2013
0e9c460
Added message and _build_message to Exception.pm
upasana-me Jun 22, 2013
f058c97
Added _build_message and removed message
upasana-me Jun 22, 2013
cb4ba0a
Added tests for cannot coerce without a type coercion
upasana-me Jun 26, 2013
d5a3560
Added exception class for coercing without type coercions
upasana-me Jun 26, 2013
fec59f7
Removed whitespace
upasana-me Jun 16, 2013
7ea490a
replaced throw_error with die Moose::Exception::CanOnlyConsumeRole
upasana-me Jun 20, 2013
32ede2d
Added super class (Exception.pm) for all the Exceptions
upasana-me Jun 22, 2013
bb6e5a7
Added message and _build_message to Exception.pm
upasana-me Jun 22, 2013
4505c42
Added tests for cannot coerce without a type coercion
upasana-me Jun 26, 2013
cc83936
added throw_exception for cannot coerce without a type coercion
upasana-me Jun 26, 2013
ff8868d
Added exception class for coercing without type coercions
upasana-me Jun 26, 2013
0fcf261
Added exception class for coercing without type coercions
upasana-me Jun 26, 2013
7aaa735
Added type to CoercingWithoutCoercion
upasana-me Jun 26, 2013
cb933e0
changed tests for coercing without type coercion
upasana-me Jun 26, 2013
fcba7b1
Wrote tests for Cannot define an accessor name on a read-only attribute
upasana-me Jun 27, 2013
863a3a1
Added tests for Single parameters to new() must be a HASH ref
upasana-me Jun 27, 2013
945f7c2
Wrote exception for Single parameters to new() must be a HASH ref
upasana-me Jun 27, 2013
1654d60
Added tests for DoesRequiresRoleName
upasana-me Jun 27, 2013
211c171
Wrote tests for AttributeIsRequired
upasana-me Jun 28, 2013
14dc7c4
Removed redundant use Moose::Exception; in all subclasses
upasana-me Jun 28, 2013
03d958a
Removed redundant use Moose::Exception; in all subclasses
upasana-me Jun 28, 2013
9b61788
Added tests for InvalidValueForIs
upasana-me Jun 28, 2013
7a97430
Wrote tests for IsaDoesNotDoTheRole & IsaLacksDoesMethod
upasana-me Jun 28, 2013
f05c672
Added tests for CoercionNeedsTypeConstraint
upasana-me Jun 29, 2013
3f7e91c
replaced throw_error with throw_exception
upasana-me Jun 29, 2013
cebd7ff
Written tests for TriggerMustBeACodeRef & CannotCoerceAWeakRef
upasana-me Jun 30, 2013
565152c
Added tests for BuilderDoesNotExist
upasana-me Jun 30, 2013
37c01e5
Wrote tests for DoesRoleTakesARoleName & AddRoleTakesAMooseMetaRoleIn…
upasana-me Jul 1, 2013
e501785
Replaced DoesRoleTakesARoleName By RoleNameRequired
upasana-me Jul 1, 2013
135af86
Wrote tests for exception thrown in Moose::Meta::Class::excludes_role
upasana-me Jul 1, 2013
719956c
Wrote tests for CanExtendsOnlyClasses
upasana-me Jul 2, 2013
d1cff9c
wrote tests for inline exception for AttributeIsRequired
upasana-me Jul 6, 2013
68869a3
Wrote tests for CannotDelegateWithoutIsa
upasana-me Jul 6, 2013
87a9558
Wrote tests for CannouAutoDerefWithoutIsa
upasana-me Jul 7, 2013
46ec7cd
Added tests for CannotAugmentIfLocalMethodPresent
upasana-me Jul 7, 2013
3dc660a
Added tests for CannotAutoDerefWithoutIsa (deleted by mistake)
upasana-me Jul 7, 2013
69c79a5
wrote tests for RequiredAttributeNeedsADefault
upasana-me Jul 7, 2013
a7bfebe
wrote tests for LazyAttributeNeedsADefault
upasana-me Jul 7, 2013
6b59d43
Wrote tests for AutoDeRefNeedsArrayRefOrHashRef
upasana-me Jul 8, 2013
052ca51
Added tests for CannotUseLazyBuildAndDefaultSimultaneously
upasana-me Jul 8, 2013
d07237a
wrote tests for CannotDelegateLocalMethodIsPresent
upasana-me Jul 8, 2013
47e304c
Wrote tests for CannotOverrideLocalMethodIsPresent
upasana-me Jul 8, 2013
0ef125f
wrote tests for inline exception for SingleParamsToNewMustBeHashRef
upasana-me Jul 8, 2013
e81a763
Changed SingleParamsToNewMustBeHRef from SingleParamsToNewMustHashRef
upasana-me Jul 8, 2013
ff25306
Added tests for RolesInCreateTakesAnArrayRef
upasana-me Jul 9, 2013
395200b
added tests for InvalidRoleApplication
upasana-me Jul 9, 2013
f7f88ed
Added tests for NoAttributeFoundInSuperClass
upasana-me Jul 9, 2013
48d1649
added tests for IllegalInheritedOptions
upasana-me Jul 9, 2013
91c8a6f
wrote tests for AttributeIsRequired in Moose::Meta::Attribute::set_value
upasana-me Jul 10, 2013
d27c034
wrote tests for ValidationFailedForTypeConstraint
upasana-me Jul 10, 2013
7fb4029
wrote tests for UnableToCanonicalizeHandles & UnableToCanonicalizeNon…
upasana-me Jul 11, 2013
d4dc945
Wrote tests for DelegationToAClassWhichIsNotLoaded
upasana-me Jul 11, 2013
8b37707
Wrote tests for DelegationToARoleWhichIsNotLoaded
upasana-me Jul 11, 2013
8ab9b93
corrected exception message of DelegationToARoleWhichIsNotLoaded
upasana-me Jul 12, 2013
6b61686
Wrote tests for DelegationToATypeWhichIsNotAClass
upasana-me Jul 12, 2013
8bd45ed
Wrote tests for CannotFindDelegateMetaClass
upasana-me Jul 12, 2013
d13e790
replaced throw_error with throw_exception
upasana-me Jul 12, 2013
463c0e8
wrote tests for BadHasProvided
upasana-me Jul 12, 2013
f943c6b
Wrote class BadHasProvided
upasana-me Jul 12, 2013
5235f9e
Wrote tests for NeitherClassNorClassNameIsGiven (thrown in Moose::Exc…
upasana-me Jul 14, 2013
8cf9a27
fixed indentation
upasana-me Jul 14, 2013
7ab99ed
Wrote tests for InitMetaRequiresClass
upasana-me Jul 14, 2013
0cfb8fb
Wrote tests for MetaclassNotLoaded
upasana-me Jul 14, 2013
242b502
Wrote tests for MetaclassMustBeASubclassOfMooseMetaClass
upasana-me Jul 14, 2013
fd9d841
replaced throw_error with throw_exception & added tests for RolesDoNo…
upasana-me Jul 15, 2013
ebf1987
Wrote tests for MustSpecifyAtleastOneMethod
upasana-me Jul 15, 2013
d8bc61e
Wrote tests for Moose::EXception::Role::Role
upasana-me Jul 15, 2013
e8051c4
Wrote tests for MustSpecifyAtleastOneRole
upasana-me Jul 15, 2013
4f6a8d2
Wrote tests for RolesDoNotSupportInner
upasana-me Jul 15, 2013
51cb7ea
wrote tests for RolesDoNotSupportAugment
upasana-me Jul 15, 2013
70699e4
Wrote some more tests for DoesRequiresRoleName
upasana-me Jul 15, 2013
9991791
Wrote tests for MustSpecifyAtleastOneRoleToApplicant
upasana-me Jul 15, 2013
91e44ff
CannotAddAsAnAttributeToARole
upasana-me Jul 15, 2013
0c6b802
Wrote tests for AttributeExtensionIsNotSupportedInRoles
upasana-me Jul 15, 2013
d8ab058
Wrote tests for CannotOverrideALocalMethod
upasana-me Jul 15, 2013
03ece2f
Wrote tests for AddRoleToARoleTakesAMooseMetaRole
upasana-me Jul 15, 2013
10130a9
Added more tests for AddRoleTakesAMooseMetaRoleInstance
upasana-me Jul 15, 2013
3b52556
Added more tests for RoleNameRequired (for Moose::Meta::Class)
upasana-me Jul 15, 2013
196f609
replaced throw_error with throw_exception & wrote tests for RoleNameR…
upasana-me Jul 16, 2013
8e2f385
replaced throw_error with throw_exception & wrote tests for ApplyTake…
upasana-me Jul 16, 2013
e1046c1
Wrote tests for exceptions in Moose::Meta::Role::create method
upasana-me Jul 16, 2013
c9a425c
changed sub foo in override exception to foo2,because it's already de…
upasana-me Jul 16, 2013
b032a63
changed test description for CannotOverrideLocalMethodIsPresent
upasana-me Jul 16, 2013
c5a8715
made a different file for exceptions thrown in lib/Moose/Object.pm
upasana-me Jul 17, 2013
a40f9c8
Wrote tests for UnionTakesAtleastTwoTypeNames & CouldNotLocateTypeCon…
upasana-me Jul 17, 2013
8349d29
added tests for InvalidTypeGivenToCreateParameterizedTypeConstraint &…
upasana-me Jul 17, 2013
c3eb323
Wrote tests for TypeConstraintIsAlreadyCreated
upasana-me Jul 17, 2013
a5d396b
corrected test message
upasana-me Jul 18, 2013
c44cad7
wrote tests for NoParentGivenToSubtype
upasana-me Jul 18, 2013
0b8f590
added tests for EnumCalledWithAnArrayRefAndAdditionalArgs
upasana-me Jul 18, 2013
2f0a421
wrote tests for UnionCalledWithAnArrayRefAndAdditionalArgs
upasana-me Jul 18, 2013
50b1664
Wrote tests for TypeConstraintIsAlreadyCreated,CannotFindType & AddPa…
upasana-me Jul 18, 2013
354266e
removed use Carp 'confess'; because now it's redundant
upasana-me Jul 25, 2013
c6d7f96
Wrote MustSupplyADelegateToMethod,MustSupplyAMooseMetaAttributeInstan…
upasana-me Jul 29, 2013
d4421e7
Added tests for MetaclassIsARoleNotASubclassOfGivenMetaclass & Metacl…
upasana-me Aug 7, 2013
f65eb6c
Changed BadHasProvided to InvalidHasProvided
upasana-me Aug 7, 2013
0527ffc
Changed BadHasProvided to InvalidHasProvided
upasana-me Aug 7, 2013
3583338
Wrote exception class OverrideMethodConflictInRoleComposition
upasana-me Aug 9, 2013
8eeacae
Added second_role attribute to RoleDoesTheExcludedRole
upasana-me Aug 10, 2013
df9262f
Wrote tests for exceptions in Moose::Meta::Method::Delegation
upasana-me Aug 24, 2013
17165db
Use CannotMakeMetaclassCompatible for all metaclass compatibility exc…
upasana-me Sep 14, 2013
976564a
Wrote CouldNotEvalDestructor
upasana-me Sep 14, 2013
b933361
Removed whitespace
upasana-me Sep 14, 2013
3268059
Use one exception for superclass metaclass incompatibility
upasana-me Sep 14, 2013
4430c82
Wrote exceptions for Moose::Util::TypeConstraints
upasana-me Sep 14, 2013
bcd5c03
Replaced throw_error with throw_exception
upasana-me Sep 14, 2013
3f32651
Wrote tests for HandOptimizedTypeConstraintIsNotCodeRef
upasana-me Sep 14, 2013
21fe82d
Wrote HandOptimizedTypeConstraintIsNotCodeRef
upasana-me Sep 14, 2013
44f16f5
Deleted MustSupplyAnArrayRefAsCurriedArguments
upasana-me Sep 15, 2013
b11074f
no need to handle hand optimized typeconstraint, it's removed now
upasana-me Sep 15, 2013
8f89f1d
removed tests for hand-optimized typeconstraint exception
upasana-me Sep 15, 2013
741a17c
removed 'An' from the exception name
upasana-me Sep 15, 2013
166a3ce
removed article from exception name
upasana-me Sep 15, 2013
676461b
used IncompatibleMetaclassOfSuperclass
upasana-me Sep 18, 2013
07b1a91
changed tests for IncompatibleMetaclassOfSuperclass
upasana-me Sep 18, 2013
5d0b302
deleted moose-meta-method-accessor.t
upasana-me Sep 23, 2013
5cd0cdd
Wrote tests for CouldNotCreateWriter
upasana-me Sep 23, 2013
a1485f0
lost this while resolving merge conflicts
upasana-me Sep 24, 2013
8de8a23
Removed redundant throw_error & _inline_throw_error
upasana-me Oct 3, 2013
b2cef83
Made changes for getting exception message of CouldNotCreateWriter
upasana-me Oct 3, 2013
5def765
Wrote documentation of Moose::Exception
upasana-me Oct 4, 2013
9eb2314
Removed redundant use Class::Load 0.07 qw(load_class);
upasana-me Oct 4, 2013
dfbe36f
Wrote documentation of Moose::Util::throw_exception
upasana-me Oct 4, 2013
f8cfcbd
Made type a duck-type, because of Specio, Type::Tiny etc.
upasana-me Oct 14, 2013
70e1be7
Made changes in documentation
upasana-me Oct 14, 2013
7a37c29
find_meta should not load Class::MOP at runtime
upasana-me Oct 16, 2013
a6dcf9d
Wrote documentation for Exceptions
upasana-me Oct 16, 2013
0528b5d
Made changes in Moose::Manual::Exceptions::Manifest
upasana-me Oct 16, 2013
903efa1
Created Moose::Manual::Exceptions::Manifest.pod
upasana-me Oct 16, 2013
d1f7101
Made changes for removing trailing whitespace
upasana-me Oct 16, 2013
c2424e0
Adding documentation with removed trailing whitespace
upasana-me Oct 16, 2013
c7490ea
Resolved a merge conflict
upasana-me Oct 16, 2013
c0f03be
Resolved conflicts
upasana-me Oct 17, 2013
1240afc
Modified auto-generated documentation
upasana-me Oct 17, 2013
b8a9e0f
Load Moose::Util::throw_exception at runtime
upasana-me Oct 17, 2013
728d584
getExceptionsToMessages should be called only once
upasana-me Oct 17, 2013
d7b03f5
Passed an array ref to enum
upasana-me Oct 17, 2013
187d145
removed trailing whitespace and tabs
upasana-me Oct 17, 2013
f2969f7
no need of pod's for Moose::Exception::*
upasana-me Oct 17, 2013
693bb90
Removed tab
upasana-me Oct 17, 2013
ee4e278
Removed tabs
upasana-me Oct 17, 2013
1eac0f5
Ignore Moose::Exception::BUILD method in pod-coverage
upasana-me Oct 17, 2013
de06757
Edited pod-spell.t
upasana-me Oct 17, 2013
448964a
Made changes in the generated documentation
upasana-me Oct 17, 2013
72e8014
Made changes in the documentation
upasana-me Oct 17, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
274 changes: 274 additions & 0 deletions docGenerator.pl
@@ -0,0 +1,274 @@
#!/usr/bin/env perl

use strict;
use warnings;

use Moose;
use Class::Load 0.07 qw(load_class);

my $dir;
my $path = 'lib/Moose/Exception/';

opendir( $dir, $path) or die $!;

my $number = 0;

print "package Moose::Manual::Exceptions::Manifest;\n";

my $exceptionsToMsgHashRef = getExceptionsToMessages();

while( my $file = readdir($dir) )
{
my %exceptions = %$exceptionsToMsgHashRef;

my ($exception, $description, $attributesText, $superclasses, $consumedRoles, $exceptionMessages);
my (@attributes, @roles, @superClasses, @rolesNames, @superClassNames);
if( !(-d 'lib/Moose/Exception/'.$file) )
{
$file =~ s/\.pm//i;

$exception = "Moose::Exception::".$file;

load_class( $exception );
my $metaClass = Class::MOP::class_of( $exception );

my @superClasses = $metaClass->superclasses;
my @roles = $metaClass->calculate_all_roles;
my @attributes = $metaClass->get_all_attributes;

my $fileHandle;

@rolesNames = map {
my $name = $_->name;
if( $name =~ /\|/ ) {
undef;
} else {
$name;
}
} @roles;

$superclasses = placeCommasAndAnd( @superClasses );
$consumedRoles = placeCommasAndAnd( @rolesNames );

foreach( @attributes )
{
my $attribute = $_;
my $name = $attribute->name;
my $traits;

if( $attribute->has_applied_traits ) {
my @traitsArray = @{$attribute->applied_traits};

$traits = "has traits of ";
my $traitsStr = placeCommasAndAnd( @traitsArray );
$traits .= $traitsStr;
}

my ( $tc, $type_constraint ) = ( $attribute->type_constraint->name, "isa " );
if( $tc =~ /::/ && !(defined $traits) ) {
$type_constraint .= "L<".$tc.">";
} else {
$type_constraint .= $tc;
}
my $readOrWrite = ( $attribute->has_writer ? 'is read-write' : 'is read-only' );
my $required = ( $attribute->is_required ? 'is required' : 'is optional' );
my $predicate = ( $attribute->has_predicate ? 'has a predicate C<'.$attribute->predicate.'>': undef );

my $default;
if( $attribute->has_default ) {
if( $tc eq "Str" ) {
$default = 'has a default value "'.$attribute->default.'"';
}
else {
$default = 'has a default value '.$attribute->default;
}
}

my $handlesText;
if( $attribute->has_handles ) {
my %handles = %{$attribute->handles};
my @keys = keys( %handles );
$handlesText = "This attribute has handles as follows:";
for( my $i = 0; $i <= $#keys; $i++ ) {
next
if( $keys[$i] =~ /^_/ );
my $strText = sprintf("\n %-25s=> %s", $keys[$i], $handles{$keys[$i]});
$handlesText .= $strText;
}
}

$exceptionMessages = "=back\n\n=head4 Sample Error Message";

my $msgOrMsgRef = $exceptions{$file};
if( ref $msgOrMsgRef eq "ARRAY" ) {
$exceptionMessages .= "s:\n\n";
my @array = @$msgOrMsgRef;
foreach( @array ) {
$exceptionMessages .= " $_";
}
} else {
$exceptionMessages .= ":\n\n";
if( $exceptions{$file} ) {
$exceptionMessages .= " ".$exceptions{$file};
}
}

$exceptionMessages .= "\n";

$attributesText .= "=item B<< \$exception->$name >>\n\n";
if( $attribute->has_documentation ) {
$attributesText .= $attribute->documentation."\n\n";
} else {
$attributesText .= "This attribute $readOrWrite, $type_constraint".
( defined $predicate ? ", $predicate" : '' ).
( defined $default ? ", $default" : '').
" and $required.".
( defined $handlesText && ( $handlesText ne "This attribute has handles as follows:\n" ) ? "\n\n$handlesText" : '' )."\n\n";
}
}
my $roleVerb = "consume".( $#roles == 0 ? 's role' : ' roles' );

my $text = "=head1 Moose::Exception::$file

This class is a subclass of $superclasses".
( defined $consumedRoles ? " and $roleVerb $consumedRoles.": '.' ).
"\n\n=over 4\n\n=back\n\n=head2 ATTRIBUTES\n\n=over 4\n\n".
( defined $attributesText ? "$attributesText" : '' );

$text = fixLineLength( $text );
$text .= $exceptionMessages;
$number++;
$text =~ s/\s+$//;
print "\n$text\n";
}
}

print "\n=cut\n";

sub fixLineLength {
my $doc = shift;

my @tokens = split /\n/, $doc;

my $str;
foreach( @tokens ) {
my $string = shortenToEighty($_);
$str .= ($string."\n");
}
return $str."\n";
}

sub shortenToEighty {
my ($str) = @_;
if( length $str > 80 && length $str != 81 ) {
my $s1 = substr($str, 0, 80);
my $s2 = substr($str, 80);
my $substr1 = substr($s1, length($s1) - 1 );
my $substr2 = substr($s2, 0, 1);
$s1 =~ s/[\s]+$//g;
$s2 =~ s/[\s]+$//g;
if( ( $substr1 =~ /[\(\)\[\w:,'"<>\]\$]/ ) && ( $substr2 =~ /[\$'"\(\)\[<>\w:,\]]/ ) ) {
if( $s1 =~ s/\s([\(\)\[<:\w+>,"'\]\$]+)$// ) {
$s1 =~ s/[\s]+$//g;
$s2 = $1.$s2;
$s2 =~ s/[\s]+$//g;
my $s3 = shortenToEighty( $s2 );
$s3 =~ s/[\s]+$//g;
$s2 =~ s/[\s]+$//g;
if( $s2 ne $s3 ) {
return "$s1\n$s3";
} else {
return "$s1\n$s2";
}
}
}
return "$s1\n$s2";
}
else
{
return $str;
}
}

sub placeCommasAndAnd {
my @array = @_;
my ($str, $lastUndef);

for( my $i = 0; $i <= $#array; $i++ ) {
my $element = $array[$i];
if( !(defined $element ) ) {
$lastUndef = 1;
next;
}
if ( $i == 0 || ( $lastUndef && $i == 1 ) ) {
$str .= "L<$element>";
} elsif( $i == $#array ) {
$str .= " and L<$element>";
} else {
$str .= ", L<$element>";
}
$lastUndef = 0;
}
return $str;
}

sub getExceptionsToMessages {
my $testDir;
my $testPath = 't/exceptions/';

my %hash;

opendir( $testDir, $testPath ) or die $!;

my $file;
while( $file = readdir( $testDir ) ) {
my $fileHandle;

open( $fileHandle, "t/exceptions/$file" ) or die $!;
my ($message, $exception);
while( <$fileHandle> ) {
if( /like\($/ ) {
my $exceptionVar = <$fileHandle>;
if( $exceptionVar =~ /\$exception,$/ ) {
$message = <$fileHandle>;
if( $message =~ q/\$\w+/ || ( $message =~ /\\\(\w+\\\)/) ) {
my $garbage = <$fileHandle>;
$message = <$fileHandle>;
$message =~ s/^\s+#//;
}
$message =~ s!^\s*qr(/|\!)(\^)?(\\Q)?!!;
$message =~ s!(/|\!),$!!;
}
} elsif( /isa_ok\($/ ) {
my $exceptionVar = <$fileHandle>;
if( $exceptionVar =~ /\$exception(->error)?,$/ ) {
$exception = <$fileHandle>;
if( $exception =~ /Moose::Exception::(\w+)/ ) {
$exception = $1;
}
}
}

if( ( defined $exception ) && ( defined $message ) ) {
if( exists $hash{$exception} &&
( ref $hash{$exception} eq "ARRAY" ) ) {
my @array = @{$hash{$exception}};
push @array, $message;
$hash{$exception} = \@array;
} elsif( exists $hash{$exception} &&
( $hash{$exception} ne $message ) ) {
my $msg = $hash{$exception};
my $arrayRef = [ $msg, $message ];
$hash{$exception} = $arrayRef;
} else {
$hash{$exception} = $message;
}
$exception = undef;
$message = undef;
}
}
close $fileHandle;
}

return \%hash;
}
1 change: 0 additions & 1 deletion lib/Class/MOP.pm
Expand Up @@ -8,7 +8,6 @@ use 5.008003;

use MRO::Compat;

use Carp 'confess';
use Scalar::Util 'weaken', 'isweak', 'reftype', 'blessed';
use Data::OptList;
use Try::Tiny;
Expand Down
50 changes: 40 additions & 10 deletions lib/Class/MOP/Attribute.pm
Expand Up @@ -12,6 +12,8 @@ use Try::Tiny;

use parent 'Class::MOP::Object', 'Class::MOP::Mixin::AttributeCore';

use Moose::Util 'throw_exception';

# NOTE: (meta-circularity)
# This method will be replaced in the
# boostrap section of Class::MOP, by
Expand All @@ -30,23 +32,34 @@ sub new {
my $name = $options{name};

(defined $name)
|| confess "You must provide a name for the attribute";
|| throw_exception( MOPAttributeNewNeedsAttributeName => class => $class,
params => \%options
);

$options{init_arg} = $name
if not exists $options{init_arg};
if(exists $options{builder}){
confess("builder must be a defined scalar value which is a method name")
throw_exception( BuilderMustBeAMethodName => class => $class,
params => \%options
)
if ref $options{builder} || !(defined $options{builder});
confess("Setting both default and builder is not allowed.")
throw_exception( BothBuilderAndDefaultAreNotAllowed => class => $class,
params => \%options
)
if exists $options{default};
} else {
($class->is_default_a_coderef(\%options))
|| confess("References are not allowed as default values, you must ".
"wrap the default of '$name' in a CODE reference (ex: sub { [] } and not [])")
|| throw_exception( ReferencesAreNotAllowedAsDefault => class => $class,
params => \%options,
attribute_name => $options{name}
)
if exists $options{default} && ref $options{default};
}

if( $options{required} and not( defined($options{builder}) || defined($options{init_arg}) || exists $options{default} ) ) {
confess("A required attribute must have either 'init_arg', 'builder', or 'default'");
throw_exception( RequiredAttributeLacksInitialization => class => $class,
params => \%options
);
}

$class->_new(\%options);
Expand Down Expand Up @@ -97,6 +110,11 @@ sub clone {
my %options = @_;
(blessed($self))
|| confess "Can only clone an instance";
# this implementation is overwritten by the bootstrap process,
# so this exception will never trigger. If it ever does occur,
# it indicates a gigantic problem with the most internal parts
# of Moose, so we wouldn't want a Moose-based exception object anyway

return bless { %{$self}, %options } => ref($self);
}

Expand Down Expand Up @@ -131,7 +149,9 @@ sub initialize_instance_slot {
);
}
else {
confess(ref($instance)." does not support builder method '". $self->{'builder'} ."' for attribute '" . $self->name . "'");
throw_exception( BuilderMethodNotSupportedForAttribute => attribute => $self,
instance => $instance
);
}
}
}
Expand Down Expand Up @@ -232,7 +252,9 @@ sub slots { (shift)->name }
sub attach_to_class {
my ($self, $class) = @_;
(blessed($class) && $class->isa('Class::MOP::Class'))
|| confess "You must pass a Class::MOP::Class instance (or a subclass)";
|| throw_exception( AttachToClassNeedsAClassMOPClassInstanceOrASubclass => attribute => $self,
class => $class
);
weaken($self->{'associated_class'} = $class);
}

Expand Down Expand Up @@ -358,7 +380,11 @@ sub _process_accessors {

if (ref($accessor)) {
(ref($accessor) eq 'HASH')
|| confess "bad accessor/reader/writer/predicate/clearer format, must be a HASH ref";
|| throw_exception( BadOptionFormat => attribute => $self,
option_value => $accessor,
option_name => $type
);

my ($name, $method) = %{$accessor};

$method_ctx->{description} = $self->_accessor_description($name, $type);
Expand Down Expand Up @@ -391,7 +417,11 @@ sub _process_accessors {
);
}
catch {
confess "Could not create the '$type' method for " . $self->name . " because : $_";
throw_exception( CouldNotCreateMethod => attribute => $self,
option_value => $accessor,
option_name => $type,
error => $_
);
};
$self->associate_method($method);
return ($accessor, $method);
Expand Down