convex
Version:
Client for the Convex Cloud
33 lines (29 loc) • 955 B
text/typescript
// This is blue #9 from https://www.radix-ui.com/docs/colors/palette-composition/the-scales
// It must look good in both light and dark mode.
const INFO_COLOR = "color:rgb(0, 145, 255)";
export function logToConsole(
type: "info" | "error",
source: "query" | "mutation",
udfPath: string,
message: string
) {
const prefix = source === "query" ? "Q" : "M";
if (type == "info") {
console.log(`%c[CONVEX ${prefix}(${udfPath})] ${message}`, INFO_COLOR);
} else {
console.error(`[CONVEX ${prefix}(${udfPath})] ${message}`);
}
}
export function logFatalError(message: string): Error {
const errorMessage = `[CONVEX FATAL ERROR] ${message}`;
console.error(errorMessage);
return new Error(errorMessage);
}
export function createError(
source: "query" | "mutation",
udfPath: string,
message: string
): Error {
const prefix = source === "query" ? "Q" : "M";
return new Error(`[CONVEX ${prefix}(${udfPath})] ${message}`);
}