We are facing problem with an endpoint that we are using for file upload. We want to send back error messages with different codes e.g. 409. We are throwing UserFriendlyException from service layer and instead of getting the standard Abp wrapper response, we are getting the actual exception like this
Abp.UI.UserFriendlyException: File with same name already exists. at ........
All of the responses in rest of the application are being wrapped in Abp standard response object and we have not added any attribute on this endpoint which would tell it not to do so. Are we missing something?
TY
!Product : zero 9.2.1, Angular, .net core
6 Answer(s)
-
0
Hi,
Dont know if this helps you but I had a similar problem back a while ago - I dont use angular though.
However I cant remember exactly what it was - but fixing the script issue fixed that problem.
I think it was to do with Swal (cant be sure though) hope this helps some.
https://support.aspnetzero.com/QA/Questions/7466/Throwing-And-Displaying-UserFriendlyException-Using-abpservicesapp
-
0
Our problem seems to be on server side.. we are expecting following response from the API endpoint { "result": null, "targetUrl": null, "success": false, "error": { "code": 409, "message": "File already exists!", "details": null, "validationErrors": null }, "unAuthorizedRequest": false, "__abp": true } but we are getting raw exception response instead..
-
0
Hi @bma
Could you share your App Service or Controller which causes this case ?
Thanks,
-
0
Hi @ismcgdas
FYI;
// this is the service method public async Task<int> UploadFile(FileDto fileDto) { // if (some logic to check fro duplicates) throw new UserFriendlyException(409, "File already exists"); // some logic to add record to db and save file on disc return 1; } public class FileDto { public int FileGroupId { get; set; } // some other fields with primitive types [Required] public IFormFile File { get; set; } }
-
0
Hi @bma
Sorry for my late reply. Could you try running your app in Production mode ? If that doesn't help, could you also share your client side code which calls this endpoint ?
Thanks,
-
0
hi ismcagdas
It was running in prod mode.
We figure out that we need to config to JsonResult specific for this ajax based multi-part form.
The probelm is solved - ty ;-)