Custom Error message from Remote Event Receiver is not displayed in Modern UI

Lars Kohsel 0 Reputation points
2024-11-25T14:12:32.3666667+00:00

When publishing a document in a SharePoint library we have a Remote Event Receiver checking various properties which may fail the publishing of the document. The Remote event receiver will return an error message which explains the reason for cancelling the publication.

It seems that Modern UI uses asynchronous calls to the SharePoint REST interface hitting the endpoint Publish() which in fact responds with an error (statuscode 500) and the correct error message.

{
"error": {

    "code": "-2130575223, Microsoft.SharePoint.SPException",

    "message": {

        "lang": "da-DK",

        "value": "PDF/HTML document(s) out of sync when publishing master document pinfoOUH-505196526-142. ServerRelativeUrl: /sites/pinfo-doc-OUH/Direktionssekretariatet/Kohsel/2024-11-13/05-01-2023_L\u00e6rCrawl.docx"

    }

  }
}

However as can be seen from the screendump below the only message being displayed to the user is "Mislykkedes", which means "failed" in danish.

Is this by design or is it a bug?

Our environment is SharePoint server 2019. Build 16.0.10404.20003

User's image

SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
3,078 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ali Koç 5 Reputation points
    2024-11-25T14:18:28.1866667+00:00

    Hello,

    I can try to help.

    Modern UI Behavior:

    • Modern UI in SharePoint uses asynchronous REST calls, which may not process or display the full custom error message returned from the backend.
    • This behavior might be by design, as the Modern UI often simplifies error messages for end users.

    Localization or Fallback Mechanism:

    • The system may default to a localized generic error message ("Mislykkedes") instead of the specific error details.

    Error Handling Differences:

    • The Modern UI might suppress or ignore detailed error messages for security or usability reasons, which could lead to the generic error being displayed instead of the full custom message.

    Best Regards,

    Ali Koc

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.