Improving error messages
This commit is contained in:
parent
dd1d8e0947
commit
66b430ac90
@ -1,5 +1,6 @@
|
|||||||
import { Colors, Path, FS, Compress, Base64 } from "../deps.ts";
|
import { Colors, Path, FS, Compress, Base64 } from "../deps.ts";
|
||||||
import { getMeta, IMeta, log, getConfig } from "../global.ts";
|
import { getMeta, IMeta, log, getConfig } from "../global.ts";
|
||||||
|
import { ServerError } from "../helper/server_error.ts";
|
||||||
|
|
||||||
async function runScript(script: string) {
|
async function runScript(script: string) {
|
||||||
console.log(Colors.bold(Colors.blue("Running script:")), script);
|
console.log(Colors.bold(Colors.blue("Running script:")), script);
|
||||||
@ -104,17 +105,20 @@ export default async function publish(options: { dry: boolean }) {
|
|||||||
.then((res) =>
|
.then((res) =>
|
||||||
res.status === 200
|
res.status === 200
|
||||||
? res.json()
|
? res.json()
|
||||||
: Promise.reject(new Error(res.statusText))
|
: Promise.reject(new ServerError(res.statusText))
|
||||||
)
|
)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (!res.success) {
|
if (!res.success) {
|
||||||
throw new Error(res.message);
|
throw new ServerError(res.message);
|
||||||
} else {
|
} else {
|
||||||
console.log(Colors.green("Upload successfull"));
|
console.log(Colors.green("Upload successfull"));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.log(Colors.red("Error: " + err.message));
|
//import { ServerError } from "../helper/server_error.ts";
|
||||||
|
if (err instanceof ServerError)
|
||||||
|
console.log(Colors.red("Server Error: " + err.message));
|
||||||
|
else console.log(Colors.red("Error: " + err.message));
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.log(Colors.yellow("Dry run. Skipping upload"));
|
console.log(Colors.yellow("Dry run. Skipping upload"));
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
export * as Compress from "https://deno.hibas123.de/raw/@denreg-tar/mod.ts";
|
export * as Compress from "https://deno.hibas123.de/raw/@denreg-tar/mod.ts";
|
||||||
export * as Ini from "https://deno.land/x/ini/mod.ts";
|
export * as Ini from "https://deno.land/x/ini@v2.1.0/mod.ts";
|
||||||
export * as Cliffy from "https://deno.land/x/cliffy/mod.ts";
|
export * as Cliffy from "https://deno.land/x/cliffy@v0.14.1/mod.ts";
|
||||||
export * as Base64 from "https://deno.land/std@0.65.0/encoding/base64.ts";
|
export * as Base64 from "https://deno.land/std@0.65.0/encoding/base64.ts";
|
||||||
export * as FS from "https://deno.land/std@0.65.0/fs/mod.ts";
|
export * as FS from "https://deno.land/std@0.65.0/fs/mod.ts";
|
||||||
export * as Colors from "https://deno.land/std@0.65.0/fmt/colors.ts";
|
export * as Colors from "https://deno.land/std@0.65.0/fmt/colors.ts";
|
||||||
|
5
cli/helper/server_error.ts
Normal file
5
cli/helper/server_error.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
export class ServerError extends Error {
|
||||||
|
constructor(message: string) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user