Customize error message

Hello there,

could you please help me on the following issue:

I want to amend the error message (error) which pops up when a user cannot access a sub-wiki. I would like to change the title from “error” to “warning message”, since it’s not actually an error and the text body as well.

Where could I find the files to change both of the above?

Many thanks,
Konstantina

Hi Konstantina,

I’m not 100% sure on this fix but from what I can understand about how the wiki works is that it uses a default set of templates which are .vm files, on my server in the /usr/lib/xwiki/templates directory there are a load of templated messages and structures. In there is also the error.vm and warning.vm which I assume are the differing error messages you’re referring to. Now if you look at error.vm you can see that it’s all commented out but makes a template reference to message.vm, if you look at that file you can see that it’s producing a text box with elements assigned for example “$!messageType”, i would assume that you could change this variable to be a standard string.

So i theory i’d say you could edit some of these template files to produce either a warning or an error. It all depends on what the default is calling. One idea might be to produce the error page and see whether there is any reference to a file for example does the source code reveal a path or file that it’s using to show this error.

Sorry I can’t be more help, someone else might respond with something better but I’ve just fixed an issue by changing a file in the widgets directory so i assumed the templates directory would work as it’s the only one that refers to errors.

Kind regards,
Callum

Look for this file on your XWiki instance https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-web/src/main/webapp/templates/accessdenied.vm#L18 and change “error” with “warning” on the highlighted line. Note down that you modified this file so you remember to redo the change when you upgrade XWiki.

Hi mflorea,
How can we change specific message in div (next to Error or warning content )?
Do we have to make any wiki template?

You either replace $services.localization.render('notallowed') with the text you want (quoted) or you change the translation for the ‘notallowed’ translation key, see https://extensions.xwiki.org/xwiki/bin/view/Extension/Localization/ .