Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions WorkflowGuidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,46 @@
let savedData = System.IO.File.ReadAllText saveFilePath.FullName
```
* Avoid applying logic based on exception's message:
Exception messages (even in stable libraries/softwares) are subject to change, applying logic based on the `Message` or `StackTrace` can cause hard-to-debug problems when updating your dependencies or in case of .NET even your framework version.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aarani "in case of .NET even your framework version"? I can't parse that, please fix; also can you update this PR to follow this please: b07ea57

Example:
```
try
let userObj = ctx.Public.Users.Create()
userObj.Id <- 1
userObj.Name <- "Alice"
ctx.SubmitUpdates()
()
with
| :? PostgresException as ex when
ex.MessageText.Contains "duplicate key value" ->
Console.WriteLine "Primary key violation was detected when adding a new user:"
Console.WriteLine (ex.ToString())
()
```
```
// Returns true if exception indicates uniqueness problem
let isDuplicatePrimaryKeyError(ex: PostgresException) =
let uniqueViolationErrorCode = "23505"
ex.SqlState = uniqueViolationErrorCode
try
let userObj = ctx.Public.Users.Create()
userObj.Id <- 1
userObj.Name <- "Alice"
ctx.SubmitUpdates()
()
with
| :? PostgresException as ex when
isDuplicatePrimaryKeyError ex ->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aarani wrong indentation length

Console.WriteLine "Primary key violation was detected when adding a new user:"
Console.WriteLine (ex.ToString())
()
```
* When contributing a PullRequest, separate your commits in units of work
(don't mix changes that have different concerns in the same commit). Don't
Expand Down