gsdriver / ssml-check-core

Core SDK for ssml-check
MIT License
13 stars 10 forks source link

add error message to unknown error types #23

Closed gowthamravichandran closed 1 year ago

gowthamravichandran commented 1 year ago

This fix helps in understanding the underlying issue with the input string better.

22

gowthamravichandran commented 1 year ago

Totally agree, I am doing something like the following for ssmllint.com (still a work in progress, do share your thoughts) Thanks to your library!

    function StringifyError(errorObj: any, text: string) {
        const lineNumber = getLineNumber(text, errorObj.position);
        if (errorObj.type === 'tag' && errorObj.attribute && errorObj.value) {
            return `The tag "${errorObj.tag}" with attribute "${errorObj.attribute}" has invalid value "${errorObj.value}" at line ${lineNumber} \n`;
        } else if (errorObj.type === 'tag' && errorObj.attribute) {
            return `The tag "${errorObj.tag}" has invalid attribute "${errorObj.attribute}" at line ${lineNumber}\n`;
        } else if (errorObj.type === 'tag') {
            return `Invalid tag "${errorObj.tag}" at line ${lineNumber}\n`;
        } else {
            return `Unknown error type: ${errorObj.type} at line ${lineNumber}\n`;
        }
    }

A crude form of handling, definitely could be improved.

Open to ideas/thoughts :)

gsdriver commented 1 year ago

Totally agree, I am doing something like the following for ssmllint.com (still a work in progress, do share your thoughts) Thanks to your library!

    function StringifyError(errorObj: any, text: string) {
        const lineNumber = getLineNumber(text, errorObj.position);
        if (errorObj.type === 'tag' && errorObj.attribute && errorObj.value) {
            return `The tag "${errorObj.tag}" with attribute "${errorObj.attribute}" has invalid value "${errorObj.value}" at line ${lineNumber} \n`;
        } else if (errorObj.type === 'tag' && errorObj.attribute) {
            return `The tag "${errorObj.tag}" has invalid attribute "${errorObj.attribute}" at line ${lineNumber}\n`;
        } else if (errorObj.type === 'tag') {
            return `Invalid tag "${errorObj.tag}" at line ${lineNumber}\n`;
        } else {
            return `Unknown error type: ${errorObj.type} at line ${lineNumber}\n`;
        }
    }

A crude form of handling, definitely could be improved.

Open to ideas/thoughts :)

Hmm .. I end up getting an error "Variant Also Negotiates" when I visit the site

gowthamravichandran commented 1 year ago

Sorry about that, still in development. was playing around with some DNS settings.

can you try now? test with some ssml strings.

ssmllint.com

Do share your thoughts! If you think we can move this discussion somewhere else more appropriate, let me know!

gsdriver commented 1 year ago

I like it - the formatting feature is pretty cool, and I appreciate the error / more detailed warning showing up at the bottom of the screen. While the formatting keeps the SSML tag structure in place, it removes the content within the tags - e.g.

<speak>Hi<break time='1s'/></speak>

becomes

<speak>
    <break time="1s"></break>
</speak>
gowthamravichandran commented 1 year ago

Good catch! the xml formatter keeps removing it. I need to fix that.

Cheers!