If user optionally pass error handling function to the send method of
rest API, request error can be processed in custom elements, e.g.:
const errFn = response => {
this.fire('page-error', {response});
};
return this.plugin.restApi().send(method, endpoint, body, errFn)
.then(r => {
Gerrit.Nav.navigateToRelativeUrl('/admin/repos');
});
Considered alternative is to handle errors in plugin requests by
providing generic function that does the same: fire page-error event,
but having a way to provide custom error function is more flexible
approach.
Change-Id: Idd7e86dd0c40d53f4327c013fa0bb469ee8a6fff