Class: MissingScopesError¶
Defined in: api.ts:276
Throw this error if the user needs to re-authenticate to gain OAuth scopes that have been added to the pack since their connection was created, or scopes that are specific to a certain formula. This is useful because Coda will always attempt to execute a formula even if a user has not yet re-authenticated with all relevant scopes.
You don't always need to throw this specific error, as Coda will interpret a 403 (Forbidden) status code error as a MissingScopesError when the user's connection was made without all currently relevant scopes. This error exists because that default behavior is insufficient if the OAuth service does not set a 403 status code (the OAuth spec doesn't specifically require them to, after all).
Example¶
try {
let response = context.fetcher.fetch({
// ...
});
} catch (error) {
// Determine if the error is due to missing scopes.
if (error.statusCode == 400 && error.body?.message.includes("permission")) {
throw new coda.MissingScopesError();
}
// Else handle or throw the error as normal.
}
See¶
Extends¶
Error
Properties¶
name¶
name:
string='MissingScopesError'
Defined in: api.ts:280
The name of the error, for identification purposes.
Overrides¶
Error.name
Methods¶
isMissingScopesError()¶
staticisMissingScopesError(err):err is MissingScopesError
Defined in: api.ts:288
Returns if the error is an instance of MissingScopesError. Note that instanceof may not work.
Parameters¶
| Parameter | Type |
|---|---|
err |
any |
Returns¶
err is MissingScopesError