Skip to content

Commit b435ed1

Browse files
committed
init
0 parents  commit b435ed1

3 files changed

Lines changed: 163 additions & 0 deletions

File tree

.gitignore

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
### Go ###
2+
# Binaries for programs and plugins
3+
*.exe
4+
*.exe~
5+
*.dll
6+
*.so
7+
*.dylib
8+
9+
# Test binary, build with `go test -c`
10+
*.test
11+
12+
# Output of the go coverage tool, specifically when used with LiteIDE
13+
*.out
14+
15+
### Go Patch ###
16+
/vendor/
17+
/Godeps/
18+
19+
### Intellij ###
20+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
21+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
22+
23+
# User-specific stuff
24+
.idea/**/workspace.xml
25+
.idea/**/tasks.xml
26+
.idea/**/usage.statistics.xml
27+
.idea/**/dictionaries
28+
.idea/**/shelf
29+
.idea
30+
# Generated files
31+
.idea/**/contentModel.xml
32+
33+
# Sensitive or high-churn files
34+
.idea/**/dataSources/
35+
.idea/**/dataSources.ids
36+
.idea/**/dataSources.local.xml
37+
.idea/**/sqlDataSources.xml
38+
.idea/**/dynamic.xml
39+
.idea/**/uiDesigner.xml
40+
.idea/**/dbnavigator.xml
41+
42+
# Gradle
43+
.idea/**/gradle.xml
44+
.idea/**/libraries
45+
46+
# Gradle and Maven with auto-import
47+
# When using Gradle or Maven with auto-import, you should exclude module files,
48+
# since they will be recreated, and may cause churn. Uncomment if using
49+
# auto-import.
50+
# .idea/modules.xml
51+
# .idea/*.iml
52+
# .idea/modules
53+
54+
# CMake
55+
cmake-build-*/
56+
57+
# Mongo Explorer plugin
58+
.idea/**/mongoSettings.xml
59+
60+
# File-based project format
61+
*.iws
62+
63+
# IntelliJ
64+
out/
65+
66+
# mpeltonen/sbt-idea plugin
67+
.idea_modules/
68+
69+
# JIRA plugin
70+
atlassian-ide-plugin.xml
71+
72+
# Cursive Clojure plugin
73+
.idea/replstate.xml
74+
75+
# Crashlytics plugin (for Android Studio and IntelliJ)
76+
com_crashlytics_export_strings.xml
77+
crashlytics.properties
78+
crashlytics-build.properties
79+
fabric.properties
80+
81+
# Editor-based Rest Client
82+
.idea/httpRequests
83+
84+
# Android studio 3.1+ serialized cache file
85+
.idea/caches/build_file_checksums.ser
86+
87+
### Intellij Patch ###
88+
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
89+
90+
*.iml
91+
modules.xml
92+
.idea/misc.xml
93+
*.ipr
94+
95+
# Sonarlint plugin
96+
.idea/sonarlint
97+
98+
### macOS ###
99+
# General
100+
.DS_Store
101+
.AppleDouble
102+
.LSOverride
103+
104+
# Icon must end with two \r
105+
Icon
106+
107+
# Thumbnails
108+
._*
109+
110+
# Files that might appear in the root of a volume
111+
.DocumentRevisions-V100
112+
.fseventsd
113+
.Spotlight-V100
114+
.TemporaryItems
115+
.Trashes
116+
.VolumeIcon.icns
117+
.com.apple.timemachine.donotpresent
118+
119+
# Directories potentially created on remote AFP share
120+
.AppleDB
121+
.AppleDesktop
122+
Network Trash Folder
123+
Temporary Items
124+
.apdisk

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module github.com/ddymko/go-jsonerror

jsonError.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package jsonError
2+
3+
import (
4+
"encoding/json"
5+
)
6+
7+
// An ErrorJson contains an array of Errors.
8+
type ErrorJSON struct {
9+
Errors []ErrorComp
10+
}
11+
12+
// An ErrorComp is a error structure that follows the json spec.
13+
type ErrorComp struct {
14+
ID string `json:"id,omitempty"`
15+
Status int `json:"status,omitempty"`
16+
Code string `json:"code,omitempty"`
17+
Title string `json:"title,omitempty"`
18+
Detail string `json:"detail,omitempty"`
19+
Source Source `json:"source,omitempty"`
20+
}
21+
22+
type Source struct {
23+
Pointer string `json:"pointer,omitempty"`
24+
}
25+
26+
func (e *ErrorJSON) Error() string {
27+
out, _ := json.Marshal(e)
28+
return string(out)
29+
}
30+
31+
func (e *ErrorJSON) ErrorByte() []byte {
32+
out, _ := json.Marshal(e)
33+
return out
34+
}
35+
36+
func (e *ErrorJSON) AddError(comp ErrorComp) {
37+
e.Errors = append(e.Errors, comp)
38+
}

0 commit comments

Comments
 (0)