@@ -783,10 +783,16 @@ export class StreamingService
783783 } catch ( e : unknown ) {
784784 console . error ( 'Error starting video transmission: ' , e ) ;
785785
786- const failureType =
787- e && ( e as any ) . message && ( e as any ) . message . includes ( 'encoder' )
788- ? 'INVALID_ENCODER'
789- : 'UNKNOWN_ERROR' ;
786+ // A blank stream key or server url fails here as a bare `UNKNOWN_ERROR`, which tells the
787+ // user nothing. Name the missing field instead when that is what went wrong.
788+ const missingSetting = this . getMissingStreamSetting ( ) ;
789+
790+ let failureType : TStreamErrorType = 'UNKNOWN_ERROR' ;
791+ if ( e && ( e as any ) . message && ( e as any ) . message . includes ( 'encoder' ) ) {
792+ failureType = 'INVALID_ENCODER' ;
793+ } else if ( missingSetting ) {
794+ failureType = missingSetting === 'key' ? 'STREAM_KEY_MISSING' : 'STREAM_SERVER_MISSING' ;
795+ }
790796
791797 const errorType = this . handleTypedStreamError (
792798 e ,
@@ -4397,6 +4403,37 @@ export class StreamingService
43974403 private streamErrorUserMessage = '' ;
43984404 private streamErrorReportMessage = '' ;
43994405
4406+ /**
4407+ * Whether an output failed because its stream settings were incomplete
4408+ * @remark OBS signals returns a generic `InvalidStream`/`BadPath` error when the stream failed to
4409+ * start due to misconfigured settings. Check for a missing key or url to surface that specific error,
4410+ * which is more helpful for the user.
4411+ * @param context - The output context that failed, as reported on the signal
4412+ * @returns The missing field, or `null` when the settings are complete
4413+ */
4414+ private getMissingStreamSetting ( context ?: string ) : 'key' | 'server' | null {
4415+ // The enhanced broadcasting instance streams Twitch, so it uses Twitch's display
4416+ let display : TDisplayType = 'horizontal' ;
4417+ if ( context === 'vertical' ) {
4418+ display = 'vertical' ;
4419+ } else if ( context === 'enhancedBroadcasting' ) {
4420+ display = this . views . getPlatformDisplayType ( 'twitch' ) ;
4421+ }
4422+
4423+ const settings =
4424+ display === 'vertical'
4425+ ? this . settingsService . views . values . StreamSecond
4426+ : this . settingsService . views . values . Stream ;
4427+
4428+ if ( ! settings . key ) return 'key' ;
4429+
4430+ // `rtmp_common` resolves the ingest from the service, so an empty server is only a problem
4431+ // for a custom ingest
4432+ if ( ! settings . server && settings . streamType !== 'rtmp_common' ) return 'server' ;
4433+
4434+ return null ;
4435+ }
4436+
44004437 private handleOBSOutputError ( info : IOBSOutputSignalInfo , platform ?: string ) {
44014438 console . log ( 'OBS Output Error signal: ' , info ) ;
44024439
@@ -4429,7 +4466,20 @@ export class StreamingService
44294466 let showNativeErrorMessage = false ;
44304467 let diagReportMessage = this . streamErrorUserMessage ;
44314468
4432- if ( info . code === EOutputCode . BadPath ) {
4469+ // Surface a more specific error for a missing stream key or server url
4470+ const missingSetting =
4471+ info . code === EOutputCode . InvalidStream || info . code === EOutputCode . BadPath
4472+ ? this . getMissingStreamSetting ( info . service )
4473+ : null ;
4474+
4475+ if ( missingSetting ) {
4476+ const messages = formatStreamErrorMessage (
4477+ missingSetting === 'key' ? 'STREAM_KEY_MISSING' : 'STREAM_SERVER_MISSING' ,
4478+ ) ;
4479+
4480+ errorText = messages . user ;
4481+ diagReportMessage = messages . report ;
4482+ } else if ( info . code === EOutputCode . BadPath ) {
44334483 errorText = $t (
44344484 'Invalid Path or Connection URL. Please check your settings to confirm that they are valid.' ,
44354485 ) ;
0 commit comments