Page 1 of 1

Customising error messages

Posted: Mon Nov 02, 2015 4:55 pm
by NissenJ
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

Re: Customising error messages

Posted: Tue Nov 03, 2015 11:30 am
by alex_jitianu
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

Re: Customising error messages

Posted: Wed Nov 04, 2015 10:05 am
by NissenJ
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

Re: Customising error messages

Posted: Wed Nov 04, 2015 11:11 am
by alex_jitianu
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

Re: Customising error messages

Posted: Wed Nov 04, 2015 11:27 am
by NissenJ
Hello,

thank you! I will try this.

Best regards,
NissenJ

Re: Customising error messages

Posted: Thu Nov 05, 2015 3:04 pm
by NissenJ
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

Re: Customising error messages

Posted: Thu Nov 05, 2015 4:04 pm
by alex_jitianu
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

Re: Customising error messages

Posted: Thu Nov 05, 2015 4:56 pm
by NissenJ
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

Re: Customising error messages

Posted: Thu Nov 05, 2015 5:48 pm
by NissenJ
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