File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import {
1717 SDK_LANGUAGE ,
1818 SDK_VERSION ,
1919 SDK_TITLE ,
20+ EXECUTABLE_NAME ,
2021} from "./constants.js" ;
2122
2223class Client {
@@ -239,6 +240,22 @@ class Client {
239240 globalConfig . setCurrentSession ( "" ) ;
240241 globalConfig . removeSession ( current ) ;
241242 }
243+
244+ const isUnauthorized =
245+ json . code === 401 &&
246+ json . type === "general_unauthorized_scope" &&
247+ typeof json . message === "string" &&
248+ / r o l e : \s * g u e s t s / i. test ( json . message ) ;
249+
250+ if ( isUnauthorized ) {
251+ throw new AppwriteException (
252+ `You are not authenticated. Run '${ EXECUTABLE_NAME } login' to authenticate and try again.` ,
253+ json . code ,
254+ json . type ,
255+ text ,
256+ ) ;
257+ }
258+
242259 throw new AppwriteException (
243260 json . message || text ,
244261 json . code ,
You can’t perform that action at this time.
0 commit comments