This repository has been archived by the owner on Jul 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b1fc539
commit 99edaef
Showing
17 changed files
with
689 additions
and
606 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
export class CoreError { | ||
|
||
} | ||
export class CoreError {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,48 @@ | ||
const ErrorMap = { | ||
commandIsEntrypoint: (info: any) => { | ||
return { | ||
info, | ||
message: `command ${ info.command } is entrypoint, cannot invoke` | ||
}; | ||
}, | ||
commandNotFound: (info: any) => { | ||
return { | ||
info, | ||
message: `command ${ info.command } not found` | ||
}; | ||
}, | ||
localPlugin: (info: any) => { | ||
return { | ||
info, | ||
message: `load local plugin '${ info.path }' error '${ info.err.message }'` | ||
}; | ||
}, | ||
npmPlugin: (info: any) => { | ||
return { | ||
info, | ||
message: `load npm plugin '${ info.path }' error '${ info.err.message }'` | ||
}; | ||
}, | ||
pluginType: (info: string) => { | ||
return { | ||
info, | ||
message: `only support npm / local / class plugin` | ||
}; | ||
} | ||
commandIsEntrypoint: (info: any) => { | ||
return { | ||
info, | ||
message: `command ${info.command} is entrypoint, cannot invoke`, | ||
}; | ||
}, | ||
commandNotFound: (info: any) => { | ||
return { | ||
info, | ||
message: `command ${info.command} not found`, | ||
}; | ||
}, | ||
localPlugin: (info: any) => { | ||
return { | ||
info, | ||
message: `load local plugin '${info.path}' error '${info.err.message}'`, | ||
}; | ||
}, | ||
npmPlugin: (info: any) => { | ||
return { | ||
info, | ||
message: `load npm plugin '${info.path}' error '${info.err.message}'`, | ||
}; | ||
}, | ||
pluginType: (info: string) => { | ||
return { | ||
info, | ||
message: `only support npm / local / class plugin`, | ||
}; | ||
}, | ||
}; | ||
|
||
interface ReturnValue<T> { | ||
info: T; | ||
message: string; | ||
interface ReturnValue<T> { | ||
info: T; | ||
message: string; | ||
} | ||
|
||
export default <T>(type: string, info: T): ReturnValue<T> => { | ||
let error = ErrorMap[type]; | ||
if (!error) { | ||
return { | ||
info, | ||
message: `error` | ||
} | ||
} | ||
return error(info); | ||
}; | ||
let error = ErrorMap[type]; | ||
if (!error) { | ||
return { | ||
info, | ||
message: `error`, | ||
}; | ||
} | ||
return error(info); | ||
}; |
Oops, something went wrong.