Custom errors

We introduce a plugin which will allow you to customize most common error messages which appear on user’s screen.

The supported scenarios are:

  • Wrong SharePoint redirect URL
  • No user license assigned (user gets deactivated)
  • Authentication error (wrong client secret, wrong connection string or wrong certificate information)
  • The KanBo  user is not added to KanBo or he has been removed from a database.

Custom error messages can be entered into `/CustomPages/PostBack.html` file which is located in the KanBo package.

This file does two things:
- forwards the successful token to the caller (handled by /Auth/PostBack.js, injected by postback)
- handles and displays the error (special function exit_auth is exported in js, so the user can retry the process)

The state is provided by the injected window.props object.

The following values are possible in the PostBack.html file :

1) The KanBo database needs migration after update

window.props = { "type": "fail:bad-db-version" }

2) User is not in kanbo (not added or removed from the database)
window.props = { "type": "fail:no-user", login: "my\\login", provider: "sp" }

3) User has no license assigned.
window.props = { "type": "fail:no-license", id: 42, name: "My Login" }

4) There's list of messages containing logs, but no error to display
window.props = { "type": "fail:unknown", "messages": ["A fail one has occured", "A fail two has occured"] }

5) There was some serious authentication error (wrong client secret, wrong connection string or wrong certificate information) that was logged into log with guid
window.props = { "type": "fail:hidden", "guid", "17C62F04-3B16-42E4-AF5A-CF9833667E4D" }

6) There wasn't any error
window.props = { "type": "success", "token": "test", "renew-data": { "some-data": 123, "test": "456" } }

Enable custom errors

1) To enable custom errors, open the PostBack.html and start editing it in the text editor.


2) In the <script> section adjust the type:

For not proper database version - window.props = { "type": "fail:bad-db-version" }
For not added/removed user - window.props = { "type": "fail:no-user", login: "my\\login", provider: "sp" }
For user with no license assigned - window.props = { "type": "fail:no-license", id: 42, name: "My Login" }
For a list of messages containing logs - window.props = { "type": "fail:unknown", "messages": ["A fail one has occured", "A fail two has occured"] }
For authentication errors - window.props = { "type": "fail:hidden", "guid", "17C62F04-3B16-42E4-AF5A-CF9833667E4D" }

For no errors - window.props = { "type": "success", "token": "test", "renew-data": { "some-data": 123, "test": "456" } }

example for No user added custom error:


3) Now scroll down and see the corresponding option (template) for that fail message. You can now configure the message in HTML.


4) You can add any custom text or enter HTML customizations of it.

5)  Save the Postback.html file once it's completed. Now restart your KanBo in IIS (On Premise/Hybrid model) or in Azure (restart in Web App option in Azure portal).


6) Now you can reproduce this issue to see it's working.

The default distribution contains error templates system,
all templates are enclosed in comment lines.

```html
<!-- error templates -->
<!-- end of error templates -->
```

Is this article helpful for you?