Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR] Expose LastOnigError() #24

Open
RedCMD opened this issue Feb 27, 2024 · 0 comments
Open

[FR] Expose LastOnigError() #24

RedCMD opened this issue Feb 27, 2024 · 0 comments

Comments

@RedCMD
Copy link

RedCMD commented Feb 27, 2024

Please expose a function that returns the last LastOnigError

I am currently able to get the error code by calling a private function inside a scanner

// @ts-ignore
const errorCode = scanner._onigBinding.UTF8ToString(scanner._onigBinding._getLastOnigError());

maybe something like:

export function lastOnigError(): string {
	if (!onigBinding) {
		throw new Error(`Must invoke loadWASM first.`);
	}
	return onigBinding.UTF8ToString(onigBinding._getLastOnigError());
}

and would it be possible to extract the location of the error as well?
index of which regex caused it
and position of the error within the regex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant