Customising error messages

Oxygen general issues.
NissenJ
Posts: 17
Joined: Thu Sep 17, 2015 3:39 pm

Customising error messages

Post 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
alex_jitianu
Posts: 1016
Joined: Wed Nov 16, 2005 11:11 am

Re: Customising error messages

Post 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
NissenJ
Posts: 17
Joined: Thu Sep 17, 2015 3:39 pm

Re: Customising error messages

Post 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
alex_jitianu
Posts: 1016
Joined: Wed Nov 16, 2005 11:11 am

Re: Customising error messages

Post 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
NissenJ
Posts: 17
Joined: Thu Sep 17, 2015 3:39 pm

Re: Customising error messages

Post by NissenJ »

Hello,

thank you! I will try this.

Best regards,
NissenJ
NissenJ
Posts: 17
Joined: Thu Sep 17, 2015 3:39 pm

Re: Customising error messages

Post 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
alex_jitianu
Posts: 1016
Joined: Wed Nov 16, 2005 11:11 am

Re: Customising error messages

Post 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
NissenJ
Posts: 17
Joined: Thu Sep 17, 2015 3:39 pm

Re: Customising error messages

Post 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
NissenJ
Posts: 17
Joined: Thu Sep 17, 2015 3:39 pm

Re: Customising error messages

Post 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
Post Reply