diff --git a/packages/language-server/src/prisma-fmt/format.ts b/packages/language-server/src/prisma-fmt/format.ts index 086c7c70b2..af785069e1 100644 --- a/packages/language-server/src/prisma-fmt/format.ts +++ b/packages/language-server/src/prisma-fmt/format.ts @@ -9,16 +9,17 @@ export default function format( console.log('running format() from prisma-fmt') try { return prismaFmt.format(schema, JSON.stringify(options)) - } catch (errors) { + } catch (e) { if (onError) { onError( "prisma-fmt error'd during formatting. To get a more detailed output please see Prisma Language Server output. To see the output, go to View > Output from the toolbar, then select 'Prisma Language Server' in the Output panel.", ) } - console.warn( + + console.error( "\nprisma-fmt error'd during formatting. Please report this issue on [Prisma Language Tools](https://github.com/prisma/language-tools/issues). \nLinter output:\n", ) - console.warn(errors) + console.error(e) return schema } diff --git a/packages/language-server/src/prisma-fmt/lint.ts b/packages/language-server/src/prisma-fmt/lint.ts index 09bf5d3003..55d24ad75e 100644 --- a/packages/language-server/src/prisma-fmt/lint.ts +++ b/packages/language-server/src/prisma-fmt/lint.ts @@ -15,15 +15,16 @@ export default function lint( try { const result = prismaFmt.lint(text) return JSON.parse(result) // eslint-disable-line @typescript-eslint/no-unsafe-return - } catch (errors) { + } catch (e) { const errorMessage = "prisma-fmt error'd during linting.\n" if (onError) { - onError(errorMessage + errors) // eslint-disable-line @typescript-eslint/restrict-plus-operands + onError(`${errorMessage} ${e as string}`) } console.error(errorMessage) - console.error(errors) + console.error(e) + return [] } } diff --git a/packages/language-server/src/prisma-fmt/nativeTypes.ts b/packages/language-server/src/prisma-fmt/nativeTypes.ts index 1e452a27fd..be614686f2 100644 --- a/packages/language-server/src/prisma-fmt/nativeTypes.ts +++ b/packages/language-server/src/prisma-fmt/nativeTypes.ts @@ -15,11 +15,17 @@ export default function nativeTypeConstructors( try { const result = prismaFmt.native_types(text) return JSON.parse(result) as NativeTypeConstructors[] - } catch (err) { + } catch (e) { + const errorMessage = + "prisma-fmt error'd during getting available native types.\n" + if (onError) { - onError(`prisma-fmt error'd during getting available native types. ${err}`) + onError(`${errorMessage} ${e as string}`) } + console.error(errorMessage) + console.error(e) + return [] } } diff --git a/packages/language-server/src/prisma-fmt/previewFeatures.ts b/packages/language-server/src/prisma-fmt/previewFeatures.ts index 7f584a0ff4..ddd6cf2ac4 100644 --- a/packages/language-server/src/prisma-fmt/previewFeatures.ts +++ b/packages/language-server/src/prisma-fmt/previewFeatures.ts @@ -7,13 +7,17 @@ export default function previewFeatures( try { const result = prismaFmt.preview_features() return JSON.parse(result) as string[] - } catch (err) { + } catch (e) { const errorMessage = "prisma-fmt error'd during getting available preview features.\n" if (onError) { - onError(errorMessage + err) + onError(`${errorMessage} ${e as string}`) } + + console.error(errorMessage) + console.error(e) + return [] } } diff --git a/packages/language-server/src/prisma-fmt/referentialActions.ts b/packages/language-server/src/prisma-fmt/referentialActions.ts index 9d2da09e0f..b6cd3da01c 100644 --- a/packages/language-server/src/prisma-fmt/referentialActions.ts +++ b/packages/language-server/src/prisma-fmt/referentialActions.ts @@ -8,11 +8,17 @@ export default function referentialActions( console.log('running referential_actions() from prisma-fmt') const result = prismaFmt.referential_actions(text) return JSON.parse(result) as string[] - } catch (err) { + } catch (e) { + const errorMessage = + "prisma-fmt error'd during getting available referential actions.\n" + if (onError) { - onError(`prisma-fmt error'd during getting available referential actions. ${err}`) + onError(`${errorMessage} ${e as string}`) } + console.error(errorMessage) + console.error(e) + return [] } }