@asgardeo/javascript
Version:
Framework agnostic JavaScript SDK for Asgardeo.
53 lines (52 loc) • 1.89 kB
TypeScript
/**
* Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import AsgardeoError from './AsgardeoError';
/**
* Base class for all API-related errors in Asgardeo. This class extends AsgardeoError
* and adds support for HTTP status codes and status text.
*
* @example
* ```typescript
* throw new AsgardeoAPIError(
* "Failed to fetch user data",
* "API_FETCH_ERROR",
* 404,
* "Not Found"
* );
* ```
*/
export default class AsgardeoAPIError extends AsgardeoError {
readonly statusCode?: number;
readonly statusText?: string;
/**
* Creates an instance of AsgardeoAPIError.
*
* @param message - Human-readable description of the error
* @param code - A unique error code that identifies the error type
* @param statusCode - HTTP status code of the failed request
* @param statusText - HTTP status text of the failed request
* @param origin - Optional. The SDK origin (e.g. 'react', 'vue'). Defaults to generic 'Asgardeo'
* @constructor
*/
constructor(message: string, code: string, origin: string, statusCode?: number, statusText?: string);
/**
* Returns a string representation of the API error
* @returns Formatted error string with name, code, status, and message
*/
toString(): string;
}