<div dir="ltr">How about something like {_error: 1, _error_code: BAD_ARGUMENT_VALUE, ...}?<br><div><div><div><br><br>I was writing something to constrain AMP Argument's in- and output values:<br><br><a href="https://github.com/lvh/txampext/blob/master/txampext/constrained.py">https://github.com/lvh/txampext/blob/master/txampext/constrained.py</a><br>
<br></div><div>... and my users getting a real exception as opposed to a disconnected transport would be nice :)<br></div><div><br></div><div>Any ticket suggestions welcome.<br></div><div><br></div></div></div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Thu, Dec 27, 2012 at 8:02 AM, Glyph <span dir="ltr"><<a href="mailto:glyph@twistedmatrix.com" target="_blank">glyph@twistedmatrix.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word"><div><div class="h5"><div><div>On Dec 26, 2012, at 1:43 PM, Laurens Van Houtven <_@lvh.cc> wrote:</div><br><blockquote type="cite"><div style="font-family:Menlo;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
<div>I'm writing a custom AMP type. I noticed that when writing the unit test for garbage input, I didn't really know what exception to check for.</div><br></div><span style="font-family:Menlo;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;display:inline!important;float:none">I couldn't find any place where this was formally defined, so I checked for implementation behavior. Boolean explicitly raises TypeError. Integer raises ValueError, but that appears to only be an implementation detail of int.</span><br style="font-family:Menlo;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
<br style="font-family:Menlo;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
<span style="font-family:Menlo;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;display:inline!important;float:none">It could also be that it doesn't matter at all, but it does seem a little strange that Integer and Boolean raise different exceptions when fed garbage...</span></blockquote>
<br></div></div></div><div>Hey Laurens,</div><div><br></div><div>This is basically a feature request :). There's no particular defined error type for argument parse errors in AMP. It's not a bad feature though. The exception also doesn't go anywhere useful - the only contract is basically that it'll bubble up and break the connection if you get some bad data. A more sophisticated and trappable / trackable way to propagate this sort of error would be useful.</div>
<div><br></div><div>(I would personally consider it a compatible change if the behavior of the error cases changed here, on the grounds that anything that uncontrollably logs a traceback in response to network input is a gross spec violation of a sort. Maybe we should add an explicit exemption for that case.)</div>
<span class="HOEnZb"><font color="#888888"><div><br></div><div>-glyph</div></font></span></div><br>_______________________________________________<br>
Twisted-Python mailing list<br>
<a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br><div dir="ltr">cheers<div>lvh</div></div>
</div>