Sharepoint Error Message When Library Permission Not Granted

Copper Contributor

Hello, I have just set up our company communication sharepoint site where users can access various document libraries from the landing page.  Different departments have different permissions.  When a member without permission clicks on a button to go to the dedicated library it displays 'Something went wrong, Cannot read properties of undefined (reading 'catch') with a retry button'.  Is there a way of changing that so it just says 'access denied' or 'you don't have permission to view this library' rather than an error message?  Obviously the retry button isn't going to do anything to assist the user.  Help appreciated, pretty new to this.


4 Replies


In SharePoint Online, you can customize the error message that appears when a user does not have permission to access a specific library. By default, SharePoint displays a generic error message, but you can modify it to provide a more informative and user-friendly message.

To customize the error message in SharePoint Online, follow these steps:

  1. Navigate to the SharePoint site where the library is located.
  2. Click on the gear icon in the upper-right corner to open the Settings menu.
  3. Select "Site Settings" from the dropdown menu.
  4. Under the "Site Collection Administration" section, click on "Site collection features."
  5. Activate the "SharePoint Server Publishing Infrastructure" feature if it is not already activated. This feature provides additional customization options for the site.
  6. Go back to the Site Settings page, and under the "Site Collection Administration" section, click on "Site collection features" again.
  7. Activate the "SharePoint Server Publishing" feature.
  8. After activating the above features, go back to the Site Settings page, and under the "Site Actions" section, click on "Site collection features" once more.
  9. Activate the "SharePoint Server Publishing" feature.
  10. Go back to the site's homepage and click on the "Page" tab in the ribbon.
  11. Click on "Edit" to edit the page where the library button is located.
  12. Select the button and click on the "Insert" tab in the ribbon.
  13. Click on "Link" to insert a link into the button.
  14. In the link properties, enter the URL of the library that users do not have permission to access.
  15. Append "?NoRedirect=True" to the end of the URL.
  16. Save and publish the page.

Now, when a user without permission clicks on the button, they will see a custom error message like "Access denied" or "You don't have permission to view this library" instead of the generic error message. This helps provide more clarity to users who do not have the necessary permissions.

Please note that the above steps require the SharePoint Server Publishing Infrastructure and SharePoint Server Publishing features to be enabled. Additionally, customization options may vary depending on the specific version and configuration of SharePoint Online in your organization.

The text and the steps were created with the help of AI.


My answer is voluntary and without guarantee.


Hope this will help you.

Many thanks @NikolinoDE 


I can see the Activate button for 'Sharepoint server publishing infrastructure' however when I click it, it goes to a 'sorry, something went wrong' page


Sorry, something went wrong
An unexpected error has occurred.

Correlation ID: 50d6c3a0-f082-6000-e43e-eb5352e666aa

Date and Time: 06/07/2023 05:40:51


Any other ideas?

@DonnaTPerega Are you using communication site template? If yes, you will not be able to activate SharePoint Server Publishing features.


Also, by default you should see access denied message if user does not have access to library. As you are getting some random and weird error message, I will suggest you to raise a support ticket with Microsoft directly and report this behavior. Follow: Get M365 support - online support 

Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

After putting "?NoRedirect=True" after the library url in the button, the button greyed out and didn't appear to work any longer. However, after removing the text and retrying it, the page now comes up with a request for access button , which is perfect, the user knows they can't access it - I would now like to do this for the other private areas but no idea how it happened as "?NoRedirect=True" has been removed :) - seems a bit glitchy