mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) move home server into core
Summary: This moves enough server material into core to run a home server. The data engine is not yet incorporated (though in manual testing it works when ported). Test Plan: existing tests pass Reviewers: dsagal Reviewed By: dsagal Differential Revision: https://phab.getgrist.com/D2552
This commit is contained in:
40
app/common/ApiError.ts
Normal file
40
app/common/ApiError.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* A tip for fixing an error.
|
||||
*/
|
||||
export interface ApiTip {
|
||||
action: 'add-members' | 'upgrade' |'ask-for-help';
|
||||
message: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Documentation of a limit relevant to an API error.
|
||||
*/
|
||||
export interface ApiLimit {
|
||||
quantity: 'collaborators' | 'docs' | 'workspaces'; // what are we counting
|
||||
subquantity?: string; // a nuance to what we are counting
|
||||
maximum: number; // maximum allowed
|
||||
value: number; // current value of quantity for user
|
||||
projectedValue: number; // value of quantity expected if request had been allowed
|
||||
}
|
||||
|
||||
/**
|
||||
* Structured details about an API error.
|
||||
*/
|
||||
export interface ApiErrorDetails {
|
||||
limit?: ApiLimit;
|
||||
|
||||
// If set, this is the more user-friendly message to show to the user than error.message.
|
||||
userError?: string;
|
||||
|
||||
// If set, contains suggestions for fixing a problem.
|
||||
tips?: ApiTip[];
|
||||
}
|
||||
|
||||
/**
|
||||
* An error with an http status code.
|
||||
*/
|
||||
export class ApiError extends Error {
|
||||
constructor(message: string, public status: number, public details?: ApiErrorDetails) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user