1
1
import { parseLanguage , Language } from "./languages" ;
2
2
import { Logger } from "./logging" ;
3
+ import { ConfigurationError } from "./util" ;
3
4
4
5
export type Credential = {
5
6
type : string ;
@@ -57,14 +58,16 @@ export function getCredentials(
57
58
} catch {
58
59
// Don't log the error since it might contain sensitive information.
59
60
logger . error ( "Failed to parse the credentials data." ) ;
60
- throw new Error ( "Invalid credentials format." ) ;
61
+ throw new ConfigurationError ( "Invalid credentials format." ) ;
61
62
}
62
63
63
64
const out : Credential [ ] = [ ] ;
64
65
for ( const e of parsed ) {
65
66
if ( e . url === undefined && e . host === undefined ) {
66
67
// 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
+ ) ;
68
71
}
69
72
70
73
// Filter credentials based on language if specified. `type` is the registry type.
@@ -85,7 +88,7 @@ export function getCredentials(
85
88
! isPrintable ( e . password ) ||
86
89
! isPrintable ( e . token )
87
90
) {
88
- throw new Error (
91
+ throw new ConfigurationError (
89
92
"Invalid credentials - fields must contain only printable characters" ,
90
93
) ;
91
94
}
0 commit comments