marklogic-community / Corona

Community REST API for MarkLogic
Other
37 stars 9 forks source link

More robust error handling on insert #49

Closed crichey closed 12 years ago

crichey commented 12 years ago

If you do a put to store with no body in the request, the request eventually times out as the code has errored out on the server. FOr example, posting to /store?uri=foo.xml with no body provides the following stack trace on the server. On the client the request just times out.

I have witnessed this type of poor error handling in other places as well, such as posting invalid fields to a search request. I think that the error handling in general should be reviewed.

Request Stack Trace Current Expression: /corona/lib/json.xqy: 156 map:map()
Global Variables $analyzeString = xdmp:function(xs:QName("fn:analyze-string")) $isSupported = fn:true() Stack Trace: /corona/lib/json.xqy: 156 json:object(("status", 500, "code", ...))
Local Variables $keyValues = ("status", 500, "code", ...) /corona/lib/common.xqy: 75 common:error("corona:INTERNAL-ERROR", "Invalid coercion (XDMP-AS: (err:XPTY0004) $content as xs:string ...", "json")
Local Variables $exceptionCode = "corona:INTERNAL-ERROR" $message = "Invalid coercion (XDMP-AS: (err:XPTY0004) $content as xs:string ..." $outputFormat = "json" $isA400 = ("corona:DUPLICATE-INDEX-NAME", "corona:DUPLICATE-PLACE-ITEM", "corona:REQUIRES-BULK-DELETE") $isA500 = ("corona:UNSUPPORTED-METHOD", "corona:INTERNAL-ERROR") $statusCode = 500 $set = () $add = () /corona/lib/common.xqy: 95 common:errorFromException(error:codeXDMP-AS/error:codeerror:nameerr:XPTY0004/error:...</error:error, "json")
Local Variables $exception = error:codeXDMP-AS/error:codeerror:nameerr:XPTY0004/error:...</error:error $outputFormat = "json" /corona/store.xqy: 162 (no expression source available)
Local Variables $requestMethod = "PUT" $params = map:map(/books/a_an.../map:map) $uri = "/books/a_and_c.xml" $txid = () $outputFormat = "json" $errors = () $e = error:codeXDMP-AS/error:codeerror:nameerr:XPTY0004/error:...</error:error

eedeebee commented 12 years ago

my 2c: good error condition handling is critical.

ryangrimm commented 12 years ago

I'm not seeing the timeout issue that you're having. How are you making the request (curl, Java, etc)?

However, I am seeing the resulting error: Invalid coercion (XDMP-AS: (err:XPTY0004) $content as xs:string -- Invalid coercion: () as xs:string).