python2ib
Version:
Convert Python code to IB Pseudocode format
80 lines • 3.41 kB
TypeScript
/**
* Custom error classes for python2ib converter
*/
export declare class PythonSyntaxError extends Error {
line?: number | undefined;
column?: number | undefined;
constructor(message: string, line?: number | undefined, column?: number | undefined);
toString(): string;
}
export declare class UnsupportedSyntaxError extends Error {
syntaxType: string;
suggestion?: string | undefined;
constructor(message: string, syntaxType: string, suggestion?: string | undefined);
toString(): string;
}
export declare class ConversionError extends Error {
originalCode?: string | undefined;
partialResult?: string | undefined;
constructor(message: string, originalCode?: string | undefined, partialResult?: string | undefined);
toString(): string;
}
export declare class ConfigurationError extends Error {
configPath?: string | undefined;
constructor(message: string, configPath?: string | undefined);
toString(): string;
}
/**
* Error messages with helpful suggestions
*/
export declare const ERROR_MESSAGES: {
readonly UNSUPPORTED_CLASS: {
readonly message: "Class definitions are not supported in IB Pseudocode";
readonly suggestion: "Convert classes to functions. Use separate functions instead of methods.";
};
readonly UNSUPPORTED_LAMBDA: {
readonly message: "Lambda functions are not supported";
readonly suggestion: "Convert lambda to a regular function definition.";
};
readonly UNSUPPORTED_LIST_COMPREHENSION: {
readonly message: "List comprehensions are not supported";
readonly suggestion: "Convert to explicit for loop with append operations.";
};
readonly UNSUPPORTED_EXCEPTION_HANDLING: {
readonly message: "Exception handling (try/except) is not supported";
readonly suggestion: "Use conditional statements to check for error conditions.";
};
readonly UNSUPPORTED_IMPORT: {
readonly message: "Import statements are not supported";
readonly suggestion: "Include necessary functions directly in your code.";
};
readonly UNSUPPORTED_DECORATOR: {
readonly message: "Decorators are not supported";
readonly suggestion: "Remove decorators and use plain function definitions.";
};
readonly UNSUPPORTED_ASYNC: {
readonly message: "Async/await syntax is not supported";
readonly suggestion: "Convert to synchronous code using regular functions.";
};
readonly UNSUPPORTED_MATCH_CASE: {
readonly message: "Match/case statements are not supported";
readonly suggestion: "Convert to if/elif/else chain.";
};
readonly INVALID_PYTHON_SYNTAX: {
readonly message: "Invalid Python syntax detected";
readonly suggestion: "Check your Python code for syntax errors before conversion.";
};
readonly EMPTY_INPUT: {
readonly message: "Empty or whitespace-only input provided";
readonly suggestion: "Provide valid Python code to convert.";
};
};
/**
* Helper function to create UnsupportedSyntaxError with predefined messages
*/
export declare function createUnsupportedSyntaxError(errorType: keyof typeof ERROR_MESSAGES, syntaxType: string): UnsupportedSyntaxError;
/**
* Helper function to format error for CLI output
*/
export declare function formatErrorForCLI(error: Error): string;
//# sourceMappingURL=index.d.ts.map