Merge lp:~benji/lazr.restful/bug-539070 into lp:lazr.restful
Proposed by
Benji York
Status: | Merged |
---|---|
Approved by: | Edwin Grubbs |
Approved revision: | 159 |
Merged at revision: | 161 |
Proposed branch: | lp:~benji/lazr.restful/bug-539070 |
Merge into: | lp:lazr.restful |
Diff against target: |
119 lines (+59/-6) 3 files modified
src/lazr/restful/_resource.py (+18/-3) src/lazr/restful/tales.py (+9/-2) src/lazr/restful/tests/test_error.py (+32/-1) |
To merge this branch: | bzr merge lp:~benji/lazr.restful/bug-539070 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Edwin Grubbs (community) | code | Approve | |
Review via email: mp+40003@code.launchpad.net |
Description of the change
Bug 539070 describes a case where an error message doesn't give much of a hint as to where to start looking for a problem. This branch enhances the error message with the interface in question so the developer knows where to look.
To post a comment you must log in.
Hi Benji,
The changes you made look good for showing which interface attribute tries to set the schema to a class that doesn't have an IEntry adapter. I just have one comment below.
-Edwin
>=== modified file 'src/lazr/ restful/ tales.py' restful/ tales.py 2010-08-24 18:57:50 +0000 restful/ tales.py 2010-11-04 19:25:16 +0000 oder, CollectionResource, lity, IObjectLink, RESTUtilityBase) _resource import UnknownEntryAdapter interfaces import ( Operation, IResourceGETOpe ration, __name_ _) lity.forSchemaI nterface( web_service_ request( )) lity.forSchemaI nterface( web_service_ request( )) pter, e: interface, self.field. getName( ))) entry_page_ type_link
>--- src/lazr/
>+++ src/lazr/
>@@ -29,6 +29,7 @@
> from lazr.restful import (
> EntryResource, ResourceJSONEnc
> EntryAdapterUti
>+from lazr.restful.
> from lazr.restful.
> ICollection, ICollectionField, IEntry, IJSONRequestCache,
> IReferenceChoice, IResourceDELETE
>@@ -540,8 +541,15 @@
> raise TypeError("Field is not of a supported type.")
> assert schema is not IObject, (
> "Null schema provided for %s" % self.field.
>- return EntryAdapterUti
>- schema, get_current_
>+ try:
>+ return EntryAdapterUti
>+ schema, get_current_
>+ except UnknownEntryAda
>+ e.whence = (
>+ 'Encountered as a result of the entry interface %r, field %r.'
>+ % (self.field.
>+ raise e
>+ return adapter.
Can you remove this line that can never be reached?