File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -345,9 +345,17 @@ func (w Window) GetChildProcessID() uint64 {
345345 return uint64 (C .webui_get_child_process_id (C .size_t (w )))
346346}
347347
348- // GetPort returns the network port of the running window.
349- func (w Window ) GetPort () int {
350- return int (C .webui_get_port (C .size_t (w )))
348+ // GetPort returns the network port of the running window. If the window isn't
349+ // running, an error is returned.
350+ func (w Window ) GetPort () (int , error ) {
351+ if ! w .IsShown () {
352+ return 0 , errors .New ("error: window is not running" )
353+ }
354+ port := int (C .webui_get_port (C .size_t (w )))
355+ if port == 0 {
356+ return 0 , errors .New ("error: failed to get port" )
357+ }
358+ return port , nil
351359}
352360
353361// SetPort sets a custom web-server network port to be used by WebUI. Returns
You can’t perform that action at this time.
0 commit comments