-
-
Notifications
You must be signed in to change notification settings - Fork 320
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
imp: cli,ui,web: begin controlling GHC 9.10+'s stack traces
- Loading branch information
1 parent
a925e73
commit 6893f34
Showing
3 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ hledger-ui - a hledger add-on providing an efficient TUI. | |
Copyright (c) 2007-2015 Simon Michael <[email protected]> | ||
Released under GPL version 3 or later. | ||
-} | ||
{-# LANGUAGE CPP #-} | ||
{-# LANGUAGE LambdaCase #-} | ||
{-# LANGUAGE MultiParamTypeClasses #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
@@ -13,6 +14,9 @@ module Hledger.UI.Main where | |
import Control.Applicative ((<|>)) | ||
import Control.Concurrent (threadDelay) | ||
import Control.Concurrent.Async (withAsync) | ||
#if MIN_VERSION_base(4,20,0) | ||
import Control.Exception.Backtrace (setBacktraceMechanismState, BacktraceMechanism(..)) | ||
#endif | ||
import Control.Monad (forM_, void, when) | ||
import Data.Bifunctor (first) | ||
import Data.Function ((&)) | ||
|
@@ -61,6 +65,14 @@ hledgerUiMain :: IO () | |
hledgerUiMain = withGhcDebug' $ withProgName "hledger-ui.log" $ do -- force Hledger.Utils.Debug.* to log to hledger-ui.log | ||
when (ghcDebugMode == GDPauseAtStart) $ ghcDebugPause' | ||
|
||
#if MIN_VERSION_base(4,20,0) | ||
-- Control ghc 9.10+'s stack traces. | ||
-- Strangely only hledger-ui has been showing them (when command line processing fails), | ||
-- even though hledger and hledger-web process it in just the same way. | ||
-- Disable them here. | ||
setBacktraceMechanismState HasCallStackBacktrace False | ||
#endif | ||
|
||
traceLogAtIO 1 "\n\n\n\n==== hledger-ui start" | ||
dbg1IO "args" progArgs | ||
dbg1IO "debugLevel" debugLevel | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,13 +5,17 @@ Copyright (c) 2007-2023 Simon Michael <[email protected]> and contributors. | |
Released under GPL version 3 or later. | ||
-} | ||
|
||
{-# LANGUAGE CPP #-} | ||
{-# LANGUAGE MultiWayIf #-} | ||
{-# LANGUAGE NamedFieldPuns #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
module Hledger.Web.Main where | ||
|
||
import Control.Exception (bracket) | ||
#if MIN_VERSION_base(4,20,0) | ||
import Control.Exception.Backtrace (setBacktraceMechanismState, BacktraceMechanism(..)) | ||
#endif | ||
import Control.Monad (when) | ||
import Data.String (fromString) | ||
import qualified Data.Text as T | ||
|
@@ -49,6 +53,12 @@ hledgerWebMain :: IO () | |
hledgerWebMain = withGhcDebug' $ do | ||
when (ghcDebugMode == GDPauseAtStart) $ ghcDebugPause' | ||
|
||
#if MIN_VERSION_base(4,20,0) | ||
-- Control ghc 9.10+'s stack traces. | ||
-- hledger-web isn't showing many yet; leave this enabled for now. | ||
setBacktraceMechanismState HasCallStackBacktrace True | ||
#endif | ||
|
||
-- try to encourage user's $PAGER to properly display ANSI (in command line help) | ||
usecolor <- useColorOnStdout | ||
when usecolor setupPager | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters