Skip to Content
Aug 02, 2022 at 10:59 AM

SAP CAP/UI5 custom error handling


Hi Experts,

I am facing issue sending JSON object as error response for OData PUT in SAP CAP and then use that object in UI5 application.

I have a scenario wherein I need to upload an excel from Fiori elements List Report app(created an upload extension) and read that from this excel in my CAP service, do some validation, if passed, insert this data in table else send data/file back to UI with error for each line where validation failed.

Upon upload from UI, I am making a PUT(because excel is sent as stream) request to my endpoint exposed via CAP and then I have a custom handler implemented for this PUT wherein I am reading data from excel and creating an array of objects using the data in excel. Till this point my app is working fine and I am able to get data using object.


Now, I want to validate some fields in this data and if there is any error in any object/row, I need to add one more property to this object to capture this error which I am able to do as well. E.g if userId starts with "2", it is invalid Id.


Now, because my file failed some validations, I need to send this file or JSON data back to my UI with errors which I am not able to send back.


My UI is able to capture this error but i am not able to capture args property holding my data


oEvent.mParameters returns this. But I need to get my "" object that i sent as error response from my service.


    "fileName": "Test1.xlsx",
    "responseRaw": "{\"error\":{\"code\":\"400\",\"message\":\"Upload failed\",\"@Common.numericSeverity\":4}}",
    "readyStateXHR": 4,
    "status": 400,
    "id": "uploadDialog--uploader"

Thanks in advance!



data.jpg (90.8 kB)
image.png (143.8 kB)
image.png (45.1 kB)
image.png (136.1 kB)