11import { parseLanguage , Language } from "./languages" ;
22import { Logger } from "./logging" ;
3+ import { ConfigurationError } from "./util" ;
34
45export type Credential = {
56 type : string ;
@@ -57,14 +58,16 @@ export function getCredentials(
5758 } catch {
5859 // Don't log the error since it might contain sensitive information.
5960 logger . error ( "Failed to parse the credentials data." ) ;
60- throw new Error ( "Invalid credentials format." ) ;
61+ throw new ConfigurationError ( "Invalid credentials format." ) ;
6162 }
6263
6364 const out : Credential [ ] = [ ] ;
6465 for ( const e of parsed ) {
6566 if ( e . url === undefined && e . host === undefined ) {
6667 // The proxy needs one of these to work. If both are defined, the url has the precedence.
67- throw new Error ( "Invalid credentials - must specify host or url" ) ;
68+ throw new ConfigurationError (
69+ "Invalid credentials - must specify host or url" ,
70+ ) ;
6871 }
6972
7073 // Filter credentials based on language if specified. `type` is the registry type.
@@ -85,7 +88,7 @@ export function getCredentials(
8588 ! isPrintable ( e . password ) ||
8689 ! isPrintable ( e . token )
8790 ) {
88- throw new Error (
91+ throw new ConfigurationError (
8992 "Invalid credentials - fields must contain only printable characters" ,
9093 ) ;
9194 }
0 commit comments