Menu

Custom error handling

Michel G.
2013-11-29
2013-12-02
  • Michel G.

    Michel G. - 2013-11-29

    Hi,

    So I've spend quit some time with CAM this week to figure out if it was a good fit for our product.

    In terms of validation capabilities: it's a 100% match. And there seems to be some bonus features that we never thought of.

    However, the errors reporting could be enriched easily I think.

    Let me explain…

    We're trying to replace our current validation process to enforce our requirements on business documents (invoices, purchase orders, stuff like that…). From the same file (here the CAM template) we'd like to be able to validate documents and create documentation about our requirements. The CAM template provide all that: it's perfect (I miss the inline as:makeMandatory attribute from the OASIS CAM official specification though…).

    Our issue is that the error reporting that CAMv generates is in plain english. Sure, we can create our own ErrorHandler but the error still stays in english. It would be great if the ErrorHandler was given the violated rules in parameters.

    So, instead of having:

    public class NodeValidator{
        [...]
        private void validateChildNode(Node node, Element xmlNode) throws AttributeException {   
            [...]
            if (elems != null && elems.size() > 1 && !node.isRepeatable()){
                errorHandler.addError(xmlNode, Constraint.isNotRepeatable);
            }
            [...]
        }
        [...]
    }
    

    We'll get something like:

    public class NodeValidator{
        [...]
        private void validateChildNode(Node node, Element xmlNode) throws AttributeException {   
            [...]
            if (elems != null && elems.size() > 1 && !node.isRepeatable()){
                errorHandler.addError(xmlNode, node, Constraint.isNotRepeatable);
            }
            [...]
        }
        [...]
    }
    

    Constraint could be an enumeration with all the kind of rules that can infringed.

    Then, the default errorHandler could translate this error in english or easily be overridden to provide an enriched message that would make more sense to the business requirement and the user.

    Does this sounds like something that CAMv could be doing one day?

    Has anyone tried something like that before?

    Thanks for your feedback!

    Michel

     
  • drrwebber

    drrwebber - 2013-11-29

    Michel, excellent suggestion, thanks!

    We will take a look into this for next week and share our thoughts back.

    I'm also thinking this might tie back into a multi-lingual configuration option similar to how we are doing that for the CAM editor also.

    David

     
  • drrwebber

    drrwebber - 2013-11-29

    BTW - just a sanity check here - assume you have found printMessage() rule, with condition expression, and that you can do WARN: this is a warning, as well as default error checking.

    That is generally how I add special condition checking - however I understand your request to allow the normal rules to also have extended capabilities.

     
  • Michel G.

    Michel G. - 2013-12-02

    David,

    Yes, that will definitely be a good thing for localization!

    Thanks for pointing out printMessage(). This is not enough but could be a temp workaround for us…

    Again, thanks for your feedback and keep me posted!

    Michel

     

Log in to post a comment.