feat: better error handling

This commit is contained in:
janishutz committed 2026-09-23 15:24:27 +02:00
1 parent bc898d6f0f
commit d1df43c57a
3 files changed
+14 -2

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@janishutz/oidc-login-sdk-browser",
"version": "1.3.5",
"version": "1.4.0",
"description": "SDK to communicate with and log into a backend running express-openid-connect",
"homepage": "https://github.com/janishutz/oidc-login-sdk#readme",
"bugs": {
+1 -1
View File
@@ -30,7 +30,7 @@ export const check = async (): Promise<boolean> => {
if ( e instanceof AuthError ) {
status = false;
} else {
throw e;
throw await e;
}
}
+12
View File
@@ -17,9 +17,13 @@ export class UnownedError extends Error {}
* @returns The reponse
*/
export const get = async ( url: string, authErrorResolution?: AuthErrorResolution ): Promise<Response> => {
try {
return await wrapper( url, {
'credentials': 'include'
}, authErrorResolution );
} catch ( e ) {
throw await e;
}
};
/**
@@ -31,6 +35,7 @@ export const get = async ( url: string, authErrorResolution?: AuthErrorResolutio
* @returns The response
*/
export const post = async ( url: string, payload: string, mime: string = 'application/json', authErrorResolution?: AuthErrorResolution ): Promise<Response> => {
try {
return await wrapper( url, {
'credentials': 'include',
'body': payload,
@@ -39,6 +44,9 @@ export const post = async ( url: string, payload: string, mime: string = 'applic
'Content-Type': mime ?? 'application/json'
}
}, authErrorResolution );
} catch ( e ) {
throw await e;
}
};
/**
@@ -48,10 +56,14 @@ export const post = async ( url: string, payload: string, mime: string = 'applic
* @returns The response
*/
export const deleteRequest = async ( url: string, authErrorResolution?: AuthErrorResolution ): Promise<Response> => {
try {
return await wrapper( url, {
'credentials': 'include',
'method': 'delete'
}, authErrorResolution );
} catch ( e ) {
throw await e;
}
};
/**