quidproquo-core
Advanced tools
Comparing version 0.0.194 to 0.0.195
import { ErrorThrowErrorActionRequester } from './ErrorThrowErrorActionRequesterTypes'; | ||
import { ErrorTypeEnum } from '../../types/ErrorTypeEnum'; | ||
export declare function askThrowError<T extends any>(errorType: ErrorTypeEnum, errorText: string, errorStack?: string): ErrorThrowErrorActionRequester<T>; | ||
import { QPQError } from '../../types/ErrorTypeEnum'; | ||
export declare function askThrowError<T extends any>(errorType: QPQError['errorType'], errorText: QPQError['errorText'], errorStack?: QPQError['errorStack']): ErrorThrowErrorActionRequester<T>; |
import { ErrorActionType } from './ErrorActionType'; | ||
import { Action, ActionProcessor, ActionRequester } from '../../types/Action'; | ||
import { ErrorTypeEnum } from '../../types/ErrorTypeEnum'; | ||
export interface ErrorThrowErrorActionPayload { | ||
errorType: ErrorTypeEnum; | ||
errorText: string; | ||
errorStack?: string; | ||
} | ||
import { QPQError } from '../../types/ErrorTypeEnum'; | ||
export type ErrorThrowErrorActionPayload = QPQError; | ||
export interface ErrorThrowErrorAction extends Action<ErrorThrowErrorActionPayload> { | ||
@@ -10,0 +6,0 @@ type: ErrorActionType.ThrowError; |
import { UserDirectoryGetUserAttributesActionRequester } from './UserDirectoryGetUserAttributesActionTypes'; | ||
export declare const UserDirectoryGetUserAttributesErrorTypeEnum: { | ||
UserNotFound: string; | ||
}; | ||
export declare function askUserDirectoryGetUserAttributes(userDirectoryName: string, username: string): UserDirectoryGetUserAttributesActionRequester; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.askUserDirectoryGetUserAttributes = void 0; | ||
exports.askUserDirectoryGetUserAttributes = exports.UserDirectoryGetUserAttributesErrorTypeEnum = void 0; | ||
const UserDirectoryActionType_1 = require("./UserDirectoryActionType"); | ||
const types_1 = require("../../types"); | ||
exports.UserDirectoryGetUserAttributesErrorTypeEnum = (0, types_1.createErrorEnumForAction)(UserDirectoryActionType_1.UserDirectoryActionType.GetUserAttributes, ['UserNotFound']); | ||
function* askUserDirectoryGetUserAttributes(userDirectoryName, username) { | ||
@@ -6,0 +8,0 @@ return yield { |
import { ActionProcessorResult } from '../types/Action'; | ||
import { ErrorTypeEnum } from '../types/ErrorTypeEnum'; | ||
import { QPQError } from '../types/ErrorTypeEnum'; | ||
export declare const actionResultError: (errorType: ErrorTypeEnum, errorText: string, errorStack?: string) => ActionProcessorResult<any>; | ||
export declare const actionResultError: (errorType: ErrorTypeEnum | string, errorText: string, errorStack?: string) => ActionProcessorResult<any>; | ||
export declare const actionResult: <T>(result: T) => ActionProcessorResult<T>; | ||
@@ -9,1 +9,6 @@ export declare const isErroredActionResult: <T>(actionResult: ActionProcessorResult<T>) => boolean; | ||
export declare const resolveActionResultError: <T>(actionResult: ActionProcessorResult<T>) => QPQError; | ||
type ErrorMap = { | ||
[key: string]: (error: Error) => ActionProcessorResult<any>; | ||
}; | ||
export declare const actionResultErrorFromCaughtError: (error: unknown, errorMap: ErrorMap) => ActionProcessorResult<any>; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.resolveActionResultError = exports.resolveActionResult = exports.isErroredActionResult = exports.actionResult = exports.actionResultError = void 0; | ||
exports.actionResultErrorFromCaughtError = exports.resolveActionResultError = exports.resolveActionResult = exports.isErroredActionResult = exports.actionResult = exports.actionResultError = void 0; | ||
const ErrorTypeEnum_1 = require("../types/ErrorTypeEnum"); | ||
@@ -33,1 +33,12 @@ const actionResultError = (errorType, errorText, errorStack) => { | ||
exports.resolveActionResultError = resolveActionResultError; | ||
const actionResultErrorFromCaughtError = (error, errorMap) => { | ||
if (error instanceof Error) { | ||
const errorName = error.name; | ||
if (errorMap[errorName]) { | ||
return errorMap[errorName](error); | ||
} | ||
return (0, exports.actionResultError)(ErrorTypeEnum_1.ErrorTypeEnum.GenericError, 'An unexpected error occurred.'); | ||
} | ||
return (0, exports.actionResultError)(ErrorTypeEnum_1.ErrorTypeEnum.GenericError, 'An unknown error occurred.'); | ||
}; | ||
exports.actionResultErrorFromCaughtError = actionResultErrorFromCaughtError; |
@@ -28,3 +28,5 @@ "use strict"; | ||
if (e instanceof Error) { | ||
return (0, actionLogic_1.actionResultError)(ErrorTypeEnum_1.ErrorTypeEnum.GenericError, e.message, e.stack); | ||
const errorName = e.name; | ||
const errorText = errorName ? `[${errorName}] - ${e.message}` : e.message; | ||
return (0, actionLogic_1.actionResultError)(ErrorTypeEnum_1.ErrorTypeEnum.GenericError, errorText, e.stack); | ||
} | ||
@@ -31,0 +33,0 @@ return (0, actionLogic_1.actionResultError)(ErrorTypeEnum_1.ErrorTypeEnum.GenericError, `An unknown error occurred in [${action === null || action === void 0 ? void 0 : action.type}]`); |
@@ -17,5 +17,5 @@ export declare enum ErrorTypeEnum { | ||
export interface QPQError { | ||
errorType: ErrorTypeEnum; | ||
errorType: ErrorTypeEnum | string; | ||
errorText: string; | ||
errorStack?: string; | ||
} |
@@ -19,1 +19,2 @@ export * from './Action'; | ||
export * from './EventMessage'; | ||
export * from './utils'; |
@@ -35,1 +35,2 @@ "use strict"; | ||
__exportStar(require("./EventMessage"), exports); | ||
__exportStar(require("./utils"), exports); |
@@ -1,2 +0,2 @@ | ||
import { ErrorTypeEnum } from './ErrorTypeEnum'; | ||
import { QPQError } from './ErrorTypeEnum'; | ||
import { Action } from './Action'; | ||
@@ -11,7 +11,2 @@ import { QpqContext } from './QpqContextIdentifier'; | ||
export type StorySessionUpdater = (newSession: Partial<StorySession>) => void; | ||
export interface StoryError { | ||
errorType: ErrorTypeEnum; | ||
errorText: string; | ||
errorStack?: string; | ||
} | ||
export type AskResponse<T> = Generator<Action<any>, T, any>; | ||
@@ -85,3 +80,3 @@ /** | ||
result?: TResult; | ||
error?: StoryError; | ||
error?: QPQError; | ||
runtimeType: QpqRuntimeType; | ||
@@ -88,0 +83,0 @@ logs?: qpqConsoleLog[]; |
{ | ||
"name": "quidproquo-core", | ||
"version": "0.0.194", | ||
"version": "0.0.195", | ||
"description": "", | ||
@@ -28,3 +28,3 @@ "main": "./lib/commonjs/index.js", | ||
"devDependencies": { | ||
"quidproquo-tsconfig": "0.0.194", | ||
"quidproquo-tsconfig": "0.0.195", | ||
"typescript": "^4.9.3" | ||
@@ -31,0 +31,0 @@ }, |
317751
514
6148