gristlabs_grist-core/app/common/ErrorWithCode.ts
Paul Fitzpatrick 6af811f7ab (core) give more detailed reasons for access denied when memos are present
Summary:
With this change, if a comment is added to an ACL formula, then that comment will be offered to the user if access is denied and that rule could potentially have granted access.

The code is factored so that when access is permitted, or when partially visible tables are being filtered, there is little overhead. Comments are gathered only when an explicit denial of access.

Test Plan: added tests, updated tests

Reviewers: dsagal

Reviewed By: dsagal

Differential Revision: https://phab.getgrist.com/D2730
2021-02-15 17:02:24 -05:00

23 lines
602 B
TypeScript

import {OpenDocMode} from 'app/common/DocListAPI';
interface ErrorDetails {
status?: number;
accessMode?: OpenDocMode;
memos?: string[];
}
/**
*
* An error with a human-readable message and a machine-readable code.
* Makes it easier to change the human-readable message without breaking
* error handlers.
*
*/
export class ErrorWithCode extends Error {
constructor(public code: string, message: string, public details: ErrorDetails = {}) {
super(message);
}
public get accessMode() { return this.details?.accessMode; }
public get status() { return this.details?.status; }
}