Improving error messages
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import { Colors, Path, FS, Compress, Base64 } from "../deps.ts";
|
||||
import { getMeta, IMeta, log, getConfig } from "../global.ts";
|
||||
import { ServerError } from "../helper/server_error.ts";
|
||||
|
||||
async function runScript(script: string) {
|
||||
console.log(Colors.bold(Colors.blue("Running script:")), script);
|
||||
@ -104,17 +105,20 @@ export default async function publish(options: { dry: boolean }) {
|
||||
.then((res) =>
|
||||
res.status === 200
|
||||
? res.json()
|
||||
: Promise.reject(new Error(res.statusText))
|
||||
: Promise.reject(new ServerError(res.statusText))
|
||||
)
|
||||
.then((res) => {
|
||||
if (!res.success) {
|
||||
throw new Error(res.message);
|
||||
throw new ServerError(res.message);
|
||||
} else {
|
||||
console.log(Colors.green("Upload successfull"));
|
||||
}
|
||||
})
|
||||
.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 {
|
||||
console.log(Colors.yellow("Dry run. Skipping upload"));
|
||||
|
Reference in New Issue
Block a user