https://www.palantir.com/docs/foundry/functions/user-facing-error/
Is there any way to make user facing error in typescript v2 similar to the one in v1 at the document above?
https://www.palantir.com/docs/foundry/functions/user-facing-error/
Is there any way to make user facing error in typescript v2 similar to the one in v1 at the document above?
Hi Jacob,
The package @osdk/legacy-client exports two user facing error types, that might be useful to you: FunctionEncounteredUserFacingError + QueryEncounteredUserFacingError
(There are a lot of other error types in there too)
I am not fully sure if this will work in e.g. Workshop, as this is the purpose of the original type.
If not, you could publish the function and import it in a TSv1 repository, where you wrap it in a function, which passes the error to a UserFacingError-type.
If you are not building in Workshop, you simple return the error as you would any other error in a TypeScript project.
Thank you for your reply.
I expected same type of red back-grounded warning to our users in workshop.
With below simple code, it works.
const fileName = (await excelFile.fetchMetadata()).filename;
if (!fileName.match(/\.(xlsx|xls)$/i)) {
userFacingError("Invalid file extension. Please upload a file with '.xlsx' or '.xls' extension.");
}
function userFacingError(message: string): never {
throw new Error(message);
}

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.