First, Corb halts on errors as a design choice. The idea is that you are
probably running Corb to make sure your content meets some minimum standard,
and if 1% of the documents throw an error then you might miss them until much
later. But if you want to open an issue and request an enhancement at
https://github.com/marklogic/corb/issues you are welcome to do so. Or you could
create a patch and a pull request, but it's probably better to talk first about
how to implement it. The Java try-catch part would probably be the easy part:
the trickier part is that Corb has a bare minimum of configurability, by
design, and a change like this would have to extend it.
But let's see if we can catch this in XQuery. I'll use the built-in
{http://marklogic.com/xdmp/dls}created index to test.
xdmp:document-insert(
'test.xml',
element test {
element { QName('http://marklogic.com/xdmp/dls', 'created') } {
current-dateTime() }})
=> ()
That works, as expected.
xdmp:document-insert(
'test.xml',
element test {
element { QName('http://marklogic.com/xdmp/dls', 'created') } {
'fubar' }})
=> XDMP-RANGEINDEX
So far so good. Let's try to catch it.
try {
xdmp:document-insert(
'test.xml',
element test {
element { QName('http://marklogic.com/xdmp/dls', 'created') } {
'fubar' }})
}
catch ($ex) { xdmp:log($ex) }
=> XDMP-RANGEINDEX
So that error is not catchable in XQuery: some errors aren't. Let's try a
different approach: it will be more work in XQuery, but won't require changes
to Corb.
try {
let $new := element test {
element { QName('http://marklogic.com/xdmp/dls', 'created') } {
'fubar' }}
let $assert := data($new//*[not(*)])
return xdmp:document-insert('test.xml', $new)
}
catch ($ex) { xdmp:log($ex) }
That avoids the error, and in the log I see XDMP-LEXVAL with details of the
problem. The trick here is that we used data() to atomize all the leaf elements
in $new, and data() will also throw an exception for lexical values that don't
match up with your range index configuration.
Now, you probably aren't calling doc-insert in your Corb module, and you
probably don't need to call data() on every leaf element either. Most likely
you are using node-replace or node-insert. That's fine: simply call data() on
the node you are about to insert, and wrap that in a try-catch. Or if the error
is in a node that you aren't updating, you can use data() to check that too. If
you have an XML schema, you might also consider a 'validate' expression.
-- Mike
On 28 Nov 2011, at 07:30 , sachin gill wrote:
>
> Yeah Michael ,
> I realized it after replying.
> When I try to parse a corrupt XML it throws below exception and shuts down
> CORB.
>
> com.marklogic.xcc.exceptions.XQueryException: XDMP-RANGEINDEX: Range index
> error:
> float
> fn:doc("/root/assets/173-cfa-study-session-17/173-cfa-study-session-17.xml")/asset/*:metadata/*:price:
> XDMP-CAST: (err:FORG0001) Invalid cast: xs:untypedAtomic("") cast as xs:float
> in /assets/corb-pipeline.xqy
> at
> com.marklogic.xcc.impl.handlers.ServerExceptionHandler.handleResponse(ServerExceptionHandler.java:30)
> at
> com.marklogic.xcc.impl.handlers.EvalRequestController.serverDialog(EvalRequestController.java:72)
> at
> com.marklogic.xcc.impl.handlers.AbstractRequestController.runRequest(AbstractRequestController.java:76)
> at
> com.marklogic.xcc.impl.SessionImpl.submitRequest(SessionImpl.java:261)
> at com.marklogic.developer.corb.Transform.call(Transform.java:68)
> at com.marklogic.developer.corb.Transform.call(Transform.java:1)
> at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
> at java.util.concurrent.FutureTask.run(Unknown Source)
> at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
> at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
> at java.util.concurrent.FutureTask.run(Unknown Source)
> at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown
> Source)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
> at java.lang.Thread.run(Unknown Source)
> Nov 28, 2011 2:28:14 AM com.marklogic.developer.corb.Manager stop
>
>
> I have one more query, does CORB also have time out issue over network, as we
> are facing abrupt stopping of CORB too when our fetched url are too large.
>
>
> Thanks
> Sachin
>
> On Mon, Nov 28, 2011 at 8:49 PM, Michael Blakeley <[email protected]> wrote:
> I think John was suggesting an XQuery try-catch expression, not a Java one.
>
> But you are more likely to get helpful suggestions if you post a full example
> of the exception you are trying to avoid. Corb throws some fatal exceptions
> of its own, when it cannot reasonably continue. It also re-throws various
> MarkLogic and XQuery exceptions. Seeing the exception that you are hitting
> would help.
>
> -- Mike
>
> On 28 Nov 2011, at 07:11 , sachin gill wrote:
>
> > HI John,
> > thanx for the suggestion but I'm using CORB jar (so that if any
> > version version upgrade happen we don;t need to do lot of customisation)
> > rather than its code , so can't handle it inside CORB code .
> >
> > Thanks
> > Sachin
> >
> > On Mon, Nov 28, 2011 at 6:50 PM, John Zhong <[email protected]> wrote:
> > First idea is that you can use try/catch. For example:
> >
> > try {
> > (: your business code here :)
> > } catch($e) {
> > (: your code to handle exception :)
> > }
> >
> > John
> >
> > On Mon, Nov 28, 2011 at 6:41 PM, sachin gill <[email protected]>
> > wrote:
> > Hi ,
> > We are facing bulk processing issue with CORB .We are using it to
> > process a large set of XML's , it works fine till it doesn't get any
> > issues or exception.Once it finds any exception it stops,And we need to
> > start from scratch again.
> >
> > How can i ignore such exception while processing and continue for other
> > xmls .
> >
> > Thanks
> > Sachin
> >
> >
> > _______________________________________________
> > General mailing list
> > [email protected]
> > http://developer.marklogic.com/mailman/listinfo/general
> >
> >
> >
> > _______________________________________________
> > General mailing list
> > [email protected]
> > http://developer.marklogic.com/mailman/listinfo/general
> >
> >
> > _______________________________________________
> > General mailing list
> > [email protected]
> > http://developer.marklogic.com/mailman/listinfo/general
>
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
>
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general