mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-01 12:26:02 +03:00
capitalize error message
Let's not assume, nor force, that the backend provides error messages in a format that we want to present. Hence we capitalize ourselves for consistency.
This commit is contained in:
parent
83893a9db3
commit
dedd721dc3
@ -22,10 +22,17 @@ export class UserError extends Error {
|
||||
const cause = error instanceof Error ? error : undefined;
|
||||
const code = error.code ?? Code.Unknown;
|
||||
const message = error.message ?? error;
|
||||
return new UserError(message, code, cause);
|
||||
return new UserError(capitalize(message), code, cause);
|
||||
}
|
||||
}
|
||||
|
||||
function capitalize(str: string): string {
|
||||
if (str.length === 0) {
|
||||
return str;
|
||||
}
|
||||
return str.charAt(0).toUpperCase() + str.slice(1);
|
||||
}
|
||||
|
||||
export async function invoke<T>(command: string, params: Record<string, unknown> = {}): Promise<T> {
|
||||
// This commented out code can be used to delay/reject an api call
|
||||
// return new Promise<T>((resolve, reject) => {
|
||||
|
Loading…
Reference in New Issue
Block a user