Skip to content

Commit

Permalink
add trymain snippet
Browse files Browse the repository at this point in the history
  • Loading branch information
WebFreak001 committed Sep 1, 2023
1 parent 0700990 commit c7ac331
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions workspace-d/source/workspaced/com/snippets/plain.d
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ static immutable PlainSnippet[] plainSnippets = [
"int main(int argc, const(char)** argv) {\n\t${0:return 0;}\n}",
"C entry point when using D with -betterC with integer status return value"
),
PlainSnippet(
[SnippetLevel.global, SnippetLevel.mixinTemplate],
"trymain",
"int main(string[] args) => try / catch",
"int main(string[] args) {\n\ttry {\n\t\t${1:run(args);}\n\t\treturn 0;\n\t} catch (Exception e) {\n\t\timport std.stdio : stderr;\n\n\t\t${2:stderr.writeln(\"Error: \", e.msg);}\n\t\t${3:debug stderr.writeln(e);}\n\n\t\treturn 1;\n\t}\n}$0",
"Normal D entry point main function with arguments and no return value"
),

// properties

Expand Down

0 comments on commit c7ac331

Please sign in to comment.