[MarkLogic Dev General] Exit query without writing to error log?

Evan Lenz evan at evanlenz.net
Wed Jan 24 16:42:50 PST 2018


Hi David,

Following up on this. I tried the custom error handler, and it appears that
the errors are not actually caught but just forwarded to the error-handler
XQuery. The impact of this for me (and which is what I'm trying to address)
is that the errors are still written to the error log, regardless of
whether they are handled by a custom error handler. Does this accord with
your understanding of how it's supposed to work?

Do you have any other ideas for how to prevent the writing to the error
log? If not, we will probably need to restructure the queries to not throw
an XQuery error at all and just send the appropriate response code and
error message. Darn, oh well.

Thanks,
Evan

On Wed, Jan 24, 2018 at 2:45 PM, Evan Lenz <evan at evanlenz.net> wrote:

> Thanks, guys. David, the custom error handler is a great idea. I had
> forgotten about this option. We're not currently using it but definitely
> will soon. It will help us move forward without fundamentally changing the
> structure of many queries. It will enable us to wrap a virtual try/catch
> around everything without having to change the code itself. Very helpful!
>
> Thanks again,
> Evan
>
>
> On Wed, Jan 24, 2018 at 4:57 AM, David Ennis <David.Ennis at marklogic.com>
> wrote:
>
>> HI.
>>
>>
>>
>> Further to Florent’s comment, assuming your code is OK with the error
>> bubbling up to the top, you can catch them all in a single place and act
>> accordingly  using a custom error handler. Using this in conjunction with
>> throwing your own errors (and handling the code in the top-level handler)
>> can be useful.
>>
>>
>>
>> https://docs.marklogic.com/guide/app-dev/appserver-control#id_89735
>>
>>
>>
>> Regards,
>>
>> David
>>
>>
>>
>> --
>>
>>
>>
>>
>>
>> *From: *<general-bounces at developer.marklogic.com> on behalf of Florent
>> Georges <lists at fgeorges.org>
>> *Reply-To: *MarkLogic Developer Discussion <general at developer.marklogic.c
>> om>
>> *Date: *Wednesday, January 24, 2018 at 1:53 PM
>> *To: *MarkLogic Developer Discussion <general at developer.marklogic.com>
>> *Subject: *Re: [MarkLogic Dev General] Exit query without writing to
>> error log?
>>
>>
>>
>> Hi Evan,
>>
>>
>>
>> The error is logged only if it "reaches the top", that is, if it is not
>> caught.
>>
>>
>>
>> If the error shouldn't behave as such, can't you just catch it before?
>> (and yes, potentially return wathever HTTP response you deem appropriate).
>>
>>
>>
>> Regards,
>>
>>
>>
>> --
>>
>> Florent Georges
>>
>> H2O Consulting
>>
>> http://h2o.consulting/
>>
>>
>>
>>
>>
>> On 24 January 2018 at 03:22, Evan Lenz wrote:
>>
>> Hello,
>>
>>
>>
>> My client has XQuery parameter-validation code which calls the error()
>> function when invalid parameters are supplied. This event gets written to
>> the error log. Is there a way to prevent this?
>>
>>
>>
>> I recognize the best practice is to return a more appropriate HTTP
>> response code (than 500) when handling invalid input. I also recognize this
>> is anathema to FP. But my question still stands:
>>
>>
>>
>> Is there a way to interrupt/exit a query without triggering an
>> Error-level log message?
>>
>>
>>
>> Thanks,
>>
>> Evan Lenz
>> President, Lenz Consulting Group, Inc.
>> http://lenzconsulting.com
>>
>>
>> _______________________________________________
>> General mailing list
>> General at developer.marklogic.com
>> Manage your subscription at:
>> http://developer.marklogic.com/mailman/listinfo/general
>>
>>
>>
>> _______________________________________________
>> General mailing list
>> General at developer.marklogic.com
>> Manage your subscription at:
>> http://developer.marklogic.com/mailman/listinfo/general
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://developer.marklogic.com/pipermail/general/attachments/20180124/319c57a6/attachment-0001.html 


More information about the General mailing list