dev: errors: improve timeclock errors
This commit is contained in:
		
							parent
							
								
									aeae7232ca
								
							
						
					
					
						commit
						78d5939c19
					
				| @ -77,14 +77,17 @@ timeclockEntriesToTransactions now (i:o:rest) | ||||
| 
 | ||||
| errorExpectedCodeButGot :: TimeclockCode -> TimeclockEntry -> a | ||||
| errorExpectedCodeButGot expected actual = error' $ printf | ||||
|   ("%s:\n%s\n\nExpected timeclock %s entry but got %s.\n" | ||||
|   ++"Only one session may be clocked in at a time, so please alternate i and o.") | ||||
|   ("%s:\n%s\n%s\n\nExpected timeclock %s entry but got %s.\n" | ||||
|   ++"Only one session may be clocked in at a time.\n" | ||||
|   ++"Please alternate i and o, beginning with i.") | ||||
|   (sourcePosPretty $ tlsourcepos actual) | ||||
|   (show l ++ " | " ++ show actual) | ||||
|   (l ++ " | " ++ show actual) | ||||
|   (replicate (length l) ' ' ++ " |" ++ replicate c ' ' ++ "^") | ||||
|   (show expected) | ||||
|   (show $ tlcode actual) | ||||
|   where | ||||
|     l = unPos $ sourceLine $ tlsourcepos actual | ||||
|     l = show $ unPos $ sourceLine $ tlsourcepos actual | ||||
|     c = unPos $ sourceColumn $ tlsourcepos actual | ||||
| 
 | ||||
| -- | Convert a timeclock clockin and clockout entry to an equivalent journal | ||||
| -- transaction, representing the time expenditure. Note this entry is  not balanced, | ||||
| @ -99,11 +102,16 @@ entryFromTimeclockInOut i o | ||||
|         ("%s:\n%s\nThis clockout time (%s) is earlier than the previous clockin.\n" | ||||
|         ++"Please adjust it to be later than %s.") | ||||
|         (sourcePosPretty $ tlsourcepos o) | ||||
|         (unlines [replicate (length l) ' '++ " | " ++ show i, l ++ " | " ++ show o]) | ||||
|         (unlines [ | ||||
|           replicate (length l) ' '++ " | " ++ show i, | ||||
|           l ++ " | " ++ show o, | ||||
|           (replicate (length l) ' ' ++ " |" ++ replicate c ' ' ++ replicate 19 '^') | ||||
|           ]) | ||||
|         (show $ tldatetime o) | ||||
|         (show $ tldatetime i) | ||||
|     where | ||||
|       l = show $ unPos $ sourceLine $ tlsourcepos o | ||||
|       c = (unPos $ sourceColumn $ tlsourcepos o) + 2 | ||||
|       t = Transaction { | ||||
|             tindex       = 0, | ||||
|             tsourcepos   = (tlsourcepos i, tlsourcepos i), | ||||
|  | ||||
| @ -55,8 +55,8 @@ Here is the current status | ||||
| | parseable-regexps        | ✓          | ✓    | ✓      | ✓✓      | ✓        | | ||||
| | payees                   | ✓          | ✓    | ✓      | ✓✓      | ✓        | | ||||
| | uniqueleafnames          | ✓          | ✓    | ✓      | ✓✓      | ✓        | | ||||
| | tcclockouttime           | ✓          | ✓    | ✓      | ✓       |          | | ||||
| | tcorderedactions         | ✓          | ✓    | ✓      | ✓       |          | | ||||
| | tcclockouttime           | ✓          | ✓    | ✓      | ✓✓      |          | | ||||
| | tcorderedactions         | ✓          | ✓    | ✓      | ✓✓      |          | | ||||
| 
 | ||||
| Key: | ||||
| - std format - the error message follows a standard format (location on first line, megaparsec-like excerpt, explanation) | ||||
| @ -111,7 +111,7 @@ Here are some current limitations of hledger's error messages: | ||||
| 
 | ||||
| <!-- to update: make readme --> | ||||
| <!-- GENERATED: --> | ||||
| hledger 1.26.99-g32c7f6300-20220714 error messages: | ||||
| hledger 1.26.99-gaeae7232c-20220714 error messages: | ||||
| 
 | ||||
| ### accounts | ||||
| ``` | ||||
| @ -282,6 +282,7 @@ Consider changing these account names so their last parts are different. | ||||
| hledger: Error: /Users/simon/src/hledger/hledger/test/errors/./tcclockouttime.timeclock:5:1: | ||||
|   | i 2022-01-01 00:01:00    | ||||
| 5 | o 2022-01-01 00:00:00    | ||||
|   |   ^^^^^^^^^^^^^^^^^^^ | ||||
| 
 | ||||
| This clockout time (2022-01-01 00:00:00) is earlier than the previous clockin. | ||||
| Please adjust it to be later than 2022-01-01 00:01:00. | ||||
| @ -292,8 +293,10 @@ Please adjust it to be later than 2022-01-01 00:01:00. | ||||
| ``` | ||||
| hledger: Error: /Users/simon/src/hledger/hledger/test/errors/./tcorderedactions.timeclock:8:1: | ||||
| 8 | i 2022-01-01 00:01:00    | ||||
|   | ^ | ||||
| 
 | ||||
| Expected timeclock o entry but got i. | ||||
| Only one session may be clocked in at a time, so please alternate i and o. | ||||
| Only one session may be clocked in at a time. | ||||
| Please alternate i and o, beginning with i. | ||||
| ``` | ||||
| 
 | ||||
|  | ||||
| @ -2,6 +2,7 @@ $$$ hledger check -f tcclockouttime.timeclock | ||||
| >>>2 /hledger: Error: .*tcclockouttime.timeclock:5:1: | ||||
|   \| i 2022-01-01 00:01:00    | ||||
| 5 \| o 2022-01-01 00:00:00    | ||||
|   \|   \^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^ | ||||
| 
 | ||||
| This clockout time \(2022-01-01 00:00:00\) is earlier than the previous clockin. | ||||
| Please adjust it to be later than 2022-01-01 00:01:00. | ||||
|  | ||||
| @ -1,8 +1,10 @@ | ||||
| $$$ hledger check -f  tcorderedactions.timeclock | ||||
| >>>2 /hledger: Error: .*tcorderedactions.timeclock:8:1: | ||||
| 8 \| i 2022-01-01 00:01:00    | ||||
|   \| \^ | ||||
| 
 | ||||
| Expected timeclock o entry but got i. | ||||
| Only one session may be clocked in at a time, so please alternate i and o. | ||||
| Only one session may be clocked in at a time. | ||||
| Please alternate i and o, beginning with i. | ||||
| / | ||||
| >>>= 1 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user