Skip to content

Commit

Permalink
Exception, Error
Browse files Browse the repository at this point in the history
  • Loading branch information
XuanThuLab committed Aug 17, 2020
1 parent a4a4257 commit 7487c1e
Show file tree
Hide file tree
Showing 29 changed files with 372 additions and 438 deletions.
Binary file removed .DS_Store
Binary file not shown.
433 changes: 0 additions & 433 deletions .gitignore

This file was deleted.

27 changes: 27 additions & 0 deletions CS015_Error_Exception/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/CS015_Error_Exception.dll",
"args": [],
"cwd": "${workspaceFolder}",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}
42 changes: 42 additions & 0 deletions CS015_Error_Exception/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/CS015_Error_Exception.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/CS015_Error_Exception.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"${workspaceFolder}/CS015_Error_Exception.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
}
]
}
9 changes: 9 additions & 0 deletions CS015_Error_Exception/CS015_Error_Exception.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>CS015_Error_Exception</RootNamespace>
</PropertyGroup>

</Project>
10 changes: 10 additions & 0 deletions CS015_Error_Exception/DataTooLongExeption.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;
namespace CS015_Error_Exception
{
public class DataTooLongExeption : Exception
{
const string erroMessage = "Dữ liệu quá dài";
public DataTooLongExeption() : base(erroMessage) {
}
}
}
47 changes: 47 additions & 0 deletions CS015_Error_Exception/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System;

namespace CS015_Error_Exception
{
class Program
{
public static void UserInput(string s) {
if (s.Length > 10)
{
Exception e = new DataTooLongExeption();
throw e; // lỗi văng ra
}
//Other code - no exeption
}
static void Main(string[] args)
{
/* Phát sinh Exception */
// int[] mynumbers = new int[] {1,2,3};
// int i = mynumbers[10]; // chỗ này phát sinh lỗi


/* Thực hành bắt lỗi Exception */
// try {
// // khối này được giám sát để bắt lỗi - khi nó phát sinh
// int[] mynumbers = new int[] {1,2,3};
// int i = mynumbers[10]; // dòng này phát sinh lỗi
// Console.WriteLine(i); // dòng này không được thực thi vì lỗi trên
// }
// catch (Exception loi)
// {
// // khối này thực thi khi bắt được lỗi
// Console.WriteLine("Có lỗi rồi");
// Console.WriteLine(loi.Message);
// }

try {
UserInput("Đây là một chuỗi rất dài ...");
}
catch (DataTooLongExeption e) {
Console.WriteLine(e.Message);
}
catch (Exception otherExeption) {
Console.WriteLine(otherExeption.Message);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v3.1",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v3.1": {
"CS015_Error_Exception/1.0.0": {
"runtime": {
"CS015_Error_Exception.dll": {}
}
}
}
},
"libraries": {
"CS015_Error_Exception/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"runtimeOptions": {
"additionalProbingPaths": [
"/Users/xuanthulab/.dotnet/store/|arch|/|tfm|",
"/Users/xuanthulab/.nuget/packages"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"runtimeOptions": {
"tfm": "netcoreapp3.1",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "3.1.0"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"format": 1,
"restore": {
"/Users/xuanthulab/Desktop/learn-cs-netcore/CS015_Error_Exception/CS015_Error_Exception.csproj": {}
},
"projects": {
"/Users/xuanthulab/Desktop/learn-cs-netcore/CS015_Error_Exception/CS015_Error_Exception.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/Users/xuanthulab/Desktop/learn-cs-netcore/CS015_Error_Exception/CS015_Error_Exception.csproj",
"projectName": "CS015_Error_Exception",
"projectPath": "/Users/xuanthulab/Desktop/learn-cs-netcore/CS015_Error_Exception/CS015_Error_Exception.csproj",
"packagesPath": "/Users/xuanthulab/.nuget/packages/",
"outputPath": "/Users/xuanthulab/Desktop/learn-cs-netcore/CS015_Error_Exception/obj/",
"projectStyle": "PackageReference",
"configFilePaths": [
"/Users/xuanthulab/.nuget/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"netcoreapp3.1"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"netcoreapp3.1": {
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"netcoreapp3.1": {
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "/usr/local/share/dotnet/sdk/3.1.401/RuntimeIdentifierGraph.json"
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/Users/xuanthulab/.nuget/packages/</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/Users/xuanthulab/.nuget/packages/</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.7.0</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="$([MSBuild]::EnsureTrailingSlash($(NuGetPackageFolders)))" />
</ItemGroup>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v3.1", FrameworkDisplayName = "")]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Reflection;

[assembly: System.Reflection.AssemblyCompanyAttribute("CS015_Error_Exception")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("CS015_Error_Exception")]
[assembly: System.Reflection.AssemblyTitleAttribute("CS015_Error_Exception")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

// Generated by the MSBuild WriteCodeFragment class.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
94c3cd2e62d3e53584464572bbcc36355058f5dc
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
c7511642836e6b9f752fc97e7822aaa1e6578257
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/Users/xuanthulab/Desktop/learn-cs-netcore/CS015_Error_Exception/bin/Debug/netcoreapp3.1/CS015_Error_Exception.deps.json
/Users/xuanthulab/Desktop/learn-cs-netcore/CS015_Error_Exception/bin/Debug/netcoreapp3.1/CS015_Error_Exception.runtimeconfig.json
/Users/xuanthulab/Desktop/learn-cs-netcore/CS015_Error_Exception/bin/Debug/netcoreapp3.1/CS015_Error_Exception.runtimeconfig.dev.json
/Users/xuanthulab/Desktop/learn-cs-netcore/CS015_Error_Exception/bin/Debug/netcoreapp3.1/CS015_Error_Exception.dll
/Users/xuanthulab/Desktop/learn-cs-netcore/CS015_Error_Exception/bin/Debug/netcoreapp3.1/CS015_Error_Exception.pdb
/Users/xuanthulab/Desktop/learn-cs-netcore/CS015_Error_Exception/obj/Debug/netcoreapp3.1/CS015_Error_Exception.csprojAssemblyReference.cache
/Users/xuanthulab/Desktop/learn-cs-netcore/CS015_Error_Exception/obj/Debug/netcoreapp3.1/CS015_Error_Exception.AssemblyInfoInputs.cache
/Users/xuanthulab/Desktop/learn-cs-netcore/CS015_Error_Exception/obj/Debug/netcoreapp3.1/CS015_Error_Exception.AssemblyInfo.cs
/Users/xuanthulab/Desktop/learn-cs-netcore/CS015_Error_Exception/obj/Debug/netcoreapp3.1/CS015_Error_Exception.csproj.CoreCompileInputs.cache
/Users/xuanthulab/Desktop/learn-cs-netcore/CS015_Error_Exception/obj/Debug/netcoreapp3.1/CS015_Error_Exception.dll
/Users/xuanthulab/Desktop/learn-cs-netcore/CS015_Error_Exception/obj/Debug/netcoreapp3.1/CS015_Error_Exception.pdb
/Users/xuanthulab/Desktop/learn-cs-netcore/CS015_Error_Exception/obj/Debug/netcoreapp3.1/CS015_Error_Exception.genruntimeconfig.cache
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
86c8e15dd33445635927cfaf398408205fd11473
Binary file not shown.
63 changes: 63 additions & 0 deletions CS015_Error_Exception/obj/project.assets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"version": 3,
"targets": {
".NETCoreApp,Version=v3.1": {}
},
"libraries": {},
"projectFileDependencyGroups": {
".NETCoreApp,Version=v3.1": []
},
"packageFolders": {
"/Users/xuanthulab/.nuget/packages/": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/Users/xuanthulab/Desktop/learn-cs-netcore/CS015_Error_Exception/CS015_Error_Exception.csproj",
"projectName": "CS015_Error_Exception",
"projectPath": "/Users/xuanthulab/Desktop/learn-cs-netcore/CS015_Error_Exception/CS015_Error_Exception.csproj",
"packagesPath": "/Users/xuanthulab/.nuget/packages/",
"outputPath": "/Users/xuanthulab/Desktop/learn-cs-netcore/CS015_Error_Exception/obj/",
"projectStyle": "PackageReference",
"configFilePaths": [
"/Users/xuanthulab/.nuget/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"netcoreapp3.1"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"netcoreapp3.1": {
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"netcoreapp3.1": {
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "/usr/local/share/dotnet/sdk/3.1.401/RuntimeIdentifierGraph.json"
}
}
}
}
8 changes: 8 additions & 0 deletions CS015_Error_Exception/obj/project.nuget.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"version": 2,
"dgSpecHash": "zmH+mCi+zGKqJA2QEEfpFxvFQEzZUsckwO6rX3Ag34QBQn9oMQTMdIrvIvh8l6oZBLIKfCsnizyfpRPUYx601g==",
"success": true,
"projectFilePath": "/Users/xuanthulab/Desktop/learn-cs-netcore/CS015_Error_Exception/CS015_Error_Exception.csproj",
"expectedPackageFiles": [],
"logs": []
}
Loading

0 comments on commit 7487c1e

Please sign in to comment.