- ABP Framework version: 7.1
- UI type: Angular
- DB provider: MongoDB
- Tiered (MVC) or Identity Server Separated (Angular): yes Microservice Solution
- Exception message and stack trace:
- Steps to reproduce the issue:"
I have seen in validation exception and Business exception as well . I am unable to change message property of object returned from api.
{
"error": {
"code": null,
"message": "Your request is not valid!",
"details": "The following errors were detected during validation.\r\n - File Size cannot be bigger than 5mb\r\n",
"data": {},
"validationErrors": [
{
"message": "File Size cannot be bigger than 5mb",
"members": null
}
]
}
}
Even though I add custom message property like below its discarded and overwritten
var validations = new List<ValidationResult>() { new ValidationResult("File Size cannot be bigger than 5mb") };
throw new AbpValidationException(message: "teesting", validations);
I also tried to use business exception but same issue. Even you pass custom message which shows up on Angular UI model as title, Default error logic overwrites it. Can you please point to me to right direction how to achieve custom Angular Ui model title for each error.
5 Answer(s)
-
0
Hi,
You can check this: https://docs.abp.io/en/abp/latest/UI/Angular/HTTP-Requests#http-error-handling
-
0
from Angular source code it seems there are default titles for each type of error and there is no way to make is different for each error.
-
0
you need to custom the error handle. https://docs.abp.io/en/abp/latest/UI/Angular/HTTP-Requests#custom-http-error-handler
-
0
Angular code is not the problem I guess . When I pass custom message property from server side like this
var validations = new List() { new ValidationResult("File Size cannot be bigger than 5mb") }; throw new AbpValidationException(message: "testing 1 2 3", validations);
API still returns message to default message for validations. Is there any way to override tis message.
{ "error": { "code": null, ** "message": "Your request is not valid!",** "details": "The following errors were detected during validation.\r\n - File Size cannot be bigger than 5mb\r\n", "data": {}, "validationErrors": [ { "message": "File Size cannot be bigger than 5mb", "members": null } ] } }
-
0
Hi,
This is by design. you can try add your own exception.
For example:
public class MyValidationException : AbpValidationException, IUserFriendlyException { public MyValidationException(string message, List<ValidationResult> validationResults) : base(message: message, validationResults) { } } var validations = new List() { new ValidationResult("File Size cannot be bigger than 5mb") }; throw new MyValidationException(message: "testing 1 2 3", validations);