Pimcore How to display custom error message in error message box - message

Hi i am working on pimcore cms.
I am calling custom API while saving objects and it has some custom error message.
Right now pimcore showing
"Object Could not saved".
How to display custom message instead of this default message in error box ?
My API returns error message whenever error occurs but I am stuck on how to pass it with pimcore Error message.
Your help will be appreciated.
Thanks

I presume you are using Pimcore events to do what you are trying to achieve. To display custom message, you just need to throw ValidationException like this:
throw new \Pimcore\Model\Element\ValidationException("This is your custom error message", 1234);
This is also described in the section Example of custom error handling using the Event API of the documentation here:
https://www.pimcore.org/docs/latest/Extending_Pimcore/Event_API_and_Event_Manager.html

Related

How to filter Outlook events by content

I want to get a list of Outlook events over the Graph API and filter them by searching for some text in the events body.
I was able to filter by subject like this:
https://graph.microsoft.com/v1.0/me/calendar/events?$filter=contains(subject,'test')
But if I try this with the body it does not work. The returned error message is either 'Invalid filter clause' or it says that an internal server error occurred. I understand that the body property of the event is not of type string, but it should be possible somehow to search in its content property
I already tried the following:
https://graph.microsoft.com/v1.0/me/calendar/events?$filter=contains(body,'test')
This returns 'Invalid filter clause'
https://graph.microsoft.com/v1.0/me/calendar/events?$filter=contains(body/content,'test')
Returns 'An internal server error occurred'
As far as I know Microsoft Graph does not support filtering for the field body

How to customize ResetPasswordAsync Error messages - Asp.net mvc?

In the ResetPassword page if user input mistake email or Manipulate code, Invalid token. error was shown.
How can I customize these Errors? For example show Incorect Email you entered instead Invalid token.
http://localhost:17594/Account/ResetPassword?userId=A&code=B
I found answer here:
How to Change Error message returned from "await UserManager.CreateAsync(user, model.Password)" ?

Formatting Error Message in rails

I have a stock validation error message that displays on the top of the screen when a field isn't met. I would like to format the message so that they display next to the field, instead of on the top of the screen. Does anyone know how I could do that?
There is a gem out there called client_side_validation which does exactly what you are looking to do. Also check out the RailsCast for an example on how to get set up with the validation library.

Unable to retrive metadata....error

Im still new to MVC and trying to follow a few tutorials (although slightly adapting them to meet my needs).
Im following the Music Store tutorial, and getting an error when trying to create a new controller in step 5 http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-5
When i try to add the controller, i get an error that says 'Unable to retrieve metadata for "myproject.models.form'. Unable to cast object of type 'System.Data.Entity.Core.Objects.ObjectContext' to type 'System.Data.Objects.ObjectContext'.
Any have any ideas how i can fix this?

vaadin error indicator and message

I want to make custom message in error indicator using Vaadin, like here: http://vaadin.com/download/book-of-vaadin/vaadin-7/html/img/application/errorindicator-example2.png
My application is multilingual and i want to have different message for the same error depending of chosen language. Is it possible to have different error messages for one error indicator? And if it's possible how to do it?
Using java.util.ResourceBundle will help your i18n issues. Each time when Locale is changed, you need to update your bundle as well. For example;
bundle = ResourceBundle.getBundle("messages", locale);
In order to retrieve error representation from bundle, you can use bundle.getString("error.message")
By doing this, you don't need to update code each time when locale is changed. Only the resource location where the representation strings is switched. For more information, http://docs.oracle.com/javase/tutorial/i18n/resbundle/prepare.html
Remember to add this code to your component:
myComponent.setConversionError("{1}");
This line of code sets your custom message to the error indicator. Otherwise you'll get this message:
Could not convert to {0}
where {0} is the name of your Converter's PRESENTATION class.
Infact this is the javadoc of the AbstractField.setConversionError(java.lang.String valueConversionError) API-method:
Sets the error that is shown if the field value cannot be converted to the data source type. If {0} is present in the message, it will be replaced by the simple name of the data source type. If {1} is present in the message, it will be replaced by the ConversionException message.

Resources