Customising error messages

<oXygen/> general issues.
NissenJ
Posts: 17

Customising error messages

Mon Nov 02, 2015 4:55 pm

Hello!

I would like to customize the error message shown in the author mode.
At the moment it says "Error while parsing external reference".
How can I change this message?

Regards,
NissenJ
alex_jitianu
Posts: 624

Re: Customising error messages

Tue Nov 03, 2015 11:30 am

Hello,

The easiest way is from the CSS, like this:

Code: Select all

oxy|error {
    visibility: -oxy-collapse-text;
}
oxy|error:after {
    content: "My own message]" !important;
}


Don't forget to decalre the oxygen namespace at the beginning of the CSS:

Code: Select all

@namespace oxy "http://www.oxygenxml.com/extensions/author";

The downside of this approach is that you will replace all error messages, not just the one you mentioned. If this is indeed an inconvenience then you can use a StyleFilter java extension. From this extension you can also check the text from the error node and set the aforementioned styles only when you should. If you need to go this way please let me know and I can offer some additional hints.

Can you give me more details on why you want to change this message? Perhaps I can come up with a different solution.

Best regards,
Alex
NissenJ
Posts: 17

Re: Customising error messages

Wed Nov 04, 2015 10:05 am

Hello,

Thank you for your help. Indeed I need different error messages.
We use our own reference resolver and the error messages should show the exact information about what went wrong depending on which exception was thrown in the java classes.
I would highly appreciate further hints on this topic, since I'm not that familiar with oxygen yet.

Thanks and regards,
NissenJ
alex_jitianu
Posts: 624

Re: Customising error messages

Wed Nov 04, 2015 11:11 am

Hello,

If you have your own reference resolver then it means you have an implementation of an AuthorReferenceResolver. On AuthorReferenceResolver.resolveReference() you can identify the error situation and throw an ReferenceResolverException in which you will give the correct error message.

Best regards,
Alex
NissenJ
Posts: 17

Re: Customising error messages

Wed Nov 04, 2015 11:27 am

Hello,

thank you! I will try this.

Best regards,
NissenJ
NissenJ
Posts: 17

Re: Customising error messages

Thu Nov 05, 2015 3:04 pm

Hello,

Now the error message is shown at the bottom of the window, where the validation problems are. But I want it to be shown directly in the document, is that possible somehow? I can send you a screenshot via e-mail if you don't know what I mean.

Regards,
NissenJ
alex_jitianu
Posts: 624

Re: Customising error messages

Thu Nov 05, 2015 4:04 pm

Hello,

Is it presented only in the results area at the bottom or both in the document and in the result area? The constructor of ReferenceResolverException has a showInResultsPanel boolean parameter. Please make sure its value is false.

Best regards,
Alex
NissenJ
Posts: 17

Re: Customising error messages

Thu Nov 05, 2015 4:56 pm

Hello,

it is presented only in the result area, not in the document. No matter what value the showInResultsPanel parameter has, the message is presented in the result area.

Regards,
NissenJ
NissenJ
Posts: 17

Re: Customising error messages

Thu Nov 05, 2015 5:48 pm

Hello,

I found my mistake, i had a return statement in my catch-phrase. The correct error message is now presented. Thank you for your help!

Best regards,
NissenJ

Return to “Other Issues”

Who is online

Users browsing this forum: No registered users and 3 guests