@@ -119,19 +119,16 @@ export async function runTui(args?: string[]): Promise<void> {
119119 try {
120120 url = new URL ( raw ) ;
121121 } catch ( err ) {
122- program . error (
122+ throw new Error (
123123 `Invalid callback URL: ${ ( err as Error ) ?. message ?? String ( err ) } ` ,
124124 ) ;
125- return { hostname : "127.0.0.1" , port : 0 , pathname : "/oauth/callback" } ; // never reached; program.error() throws
126125 }
127126 if ( url . protocol !== "http:" ) {
128- program . error ( "Callback URL must use http scheme" ) ;
129- return { hostname : "127.0.0.1" , port : 0 , pathname : "/oauth/callback" } ; // never reached; program.error() throws
127+ throw new Error ( "Callback URL must use http scheme" ) ;
130128 }
131129 const hostname = url . hostname ;
132130 if ( ! hostname ) {
133- program . error ( "Callback URL must include a hostname" ) ;
134- return { hostname : "127.0.0.1" , port : 0 , pathname : "/oauth/callback" } ; // never reached; program.error() throws
131+ throw new Error ( "Callback URL must include a hostname" ) ;
135132 }
136133 const pathname = url . pathname || "/" ;
137134 let port : number ;
@@ -145,13 +142,21 @@ export async function runTui(args?: string[]): Promise<void> {
145142 port < 0 ||
146143 port > 65535
147144 ) {
148- program . error ( "Callback URL port must be between 0 and 65535" ) ;
145+ throw new Error ( "Callback URL port must be between 0 and 65535" ) ;
149146 }
150147 }
151148 return { hostname, port, pathname } ;
152149 }
153150
154- const callbackUrlConfig = parseCallbackUrl ( options . callbackUrl ) ;
151+ let callbackUrlConfig : CallbackUrlConfig ;
152+ try {
153+ callbackUrlConfig = parseCallbackUrl ( options . callbackUrl ) ;
154+ } catch ( err ) {
155+ if ( err instanceof Error ) {
156+ program . error ( err . message ) ;
157+ }
158+ throw err ;
159+ }
155160
156161 // Intercept stdout.write to filter out \x1b[3J (Erase Saved Lines)
157162 // This prevents Ink's clearTerminal from clearing scrollback on macOS Terminal
0 commit comments