Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: add some java exception #75

Merged
merged 2 commits into from
Jun 16, 2019
Merged
Show file tree
Hide file tree
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
14 changes: 14 additions & 0 deletions java_exception.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,18 @@ func init() {
RegisterPOJO(&java_exception.IllegalStateException{})
RegisterPOJO(&java_exception.IllegalMonitorStateException{})
RegisterPOJO(&java_exception.EnumConstantNotPresentException{})
RegisterPOJO(&java_exception.NullPointerException{})
RegisterPOJO(&java_exception.UncheckedIOException{})
RegisterPOJO(&java_exception.FileNotFoundException{})
RegisterPOJO(&java_exception.EOFException{})
RegisterPOJO(&java_exception.SyncFailedException{})
RegisterPOJO(&java_exception.ObjectStreamException{})
RegisterPOJO(&java_exception.WriteAbortedException{})
RegisterPOJO(&java_exception.InvalidObjectException{})
RegisterPOJO(&java_exception.StreamCorruptedException{})
RegisterPOJO(&java_exception.InvalidClassException{})
RegisterPOJO(&java_exception.OptionalDataException{})
RegisterPOJO(&java_exception.NotActiveException{})
RegisterPOJO(&java_exception.NotSerializableException{})
RegisterPOJO(&java_exception.UTFDataFormatException{})
}
35 changes: 35 additions & 0 deletions java_exception/EOF_exception.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright 2016-2019 [email protected]
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package java_exception

type EOFException struct {
SerialVersionUID int64
DetailMessage string
StackTrace []StackTraceElement
SuppressedExceptions []EOFException
Cause *EOFException
}

func NewEOFException(detailMessage string) *EOFException {
return &EOFException{DetailMessage: detailMessage, StackTrace: []StackTraceElement{}}
}

func (e EOFException) Error() string {
return e.DetailMessage
}

func (EOFException) JavaClassName() string {
return "java.io.EOFException"
}
35 changes: 35 additions & 0 deletions java_exception/file_not_found_exception.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright 2016-2019 [email protected]
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package java_exception

type FileNotFoundException struct {
SerialVersionUID int64
DetailMessage string
StackTrace []StackTraceElement
SuppressedExceptions []FileNotFoundException
Cause *FileNotFoundException
}

func NewFileNotFoundException(detailMessage string) *FileNotFoundException {
return &FileNotFoundException{DetailMessage: detailMessage, StackTrace: []StackTraceElement{}}
}

func (e FileNotFoundException) Error() string {
return e.DetailMessage
}

func (FileNotFoundException) JavaClassName() string {
return "java.io.FileNotFoundException"
}
43 changes: 43 additions & 0 deletions java_exception/invalid_class_exception.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright 2016-2019 [email protected]
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package java_exception

import "fmt"

type InvalidClassException struct {
SerialVersionUID int64
DetailMessage string
StackTrace []StackTraceElement
Classname string
SuppressedExceptions []InvalidClassException
Cause *InvalidClassException
}

func NewInvalidClassException(classname string, detailMessage string) *InvalidClassException {
return &InvalidClassException{DetailMessage: detailMessage, StackTrace: []StackTraceElement{},
Classname: classname}
}

func (e InvalidClassException) Error() string {
if len(e.Classname) <= 0 {
return e.DetailMessage
}
return fmt.Sprintf("%+v; %+v", e.Classname, e.DetailMessage)

}

func (InvalidClassException) JavaClassName() string {
return "java.io.InvalidClassException"
}
35 changes: 35 additions & 0 deletions java_exception/invalid_object_exception.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright 2016-2019 [email protected]
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package java_exception

type InvalidObjectException struct {
SerialVersionUID int64
DetailMessage string
StackTrace []StackTraceElement
SuppressedExceptions []InvalidObjectException
Cause *InvalidObjectException
}

func NewInvalidObjectException(detailMessage string) *InvalidObjectException {
return &InvalidObjectException{DetailMessage: detailMessage, StackTrace: []StackTraceElement{}}
}

func (e InvalidObjectException) Error() string {
return e.DetailMessage
}

func (InvalidObjectException) JavaClassName() string {
return "java.io.InvalidObjectException"
}
35 changes: 35 additions & 0 deletions java_exception/not_active_exception.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright 2016-2019 [email protected]
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package java_exception

type NotActiveException struct {
SerialVersionUID int64
DetailMessage string
StackTrace []StackTraceElement
SuppressedExceptions []NotActiveException
Cause *NotActiveException
}

func NewNotActiveException(detailMessage string) *NotActiveException {
return &NotActiveException{DetailMessage: detailMessage}
}

func (e NotActiveException) Error() string {
return e.DetailMessage
}

func (NotActiveException) JavaClassName() string {
return "java.io.NotActiveException"
}
35 changes: 35 additions & 0 deletions java_exception/not_serializable_exception.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright 2016-2019 [email protected]
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package java_exception

type NotSerializableException struct {
SerialVersionUID int64
DetailMessage string
StackTrace []StackTraceElement
SuppressedExceptions []NotSerializableException
Cause *NotSerializableException
}

func NewNotSerializableException(detailMessage string) *NotActiveException {
return &NotActiveException{DetailMessage: detailMessage}
}

func (e NotSerializableException) Error() string {
return e.DetailMessage
}

func (NotSerializableException) JavaClassName() string {
return "java.io.NotSerializableException"
}
35 changes: 35 additions & 0 deletions java_exception/null_pointer_exception.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright 2016-2019 [email protected]
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package java_exception

type NullPointerException struct {
SerialVersionUID int64
DetailMessage string
StackTrace []StackTraceElement
SuppressedExceptions []NullPointerException
Cause *NullPointerException
}

func NewNullPointerException(detailMessage string) *NullPointerException {
return &NullPointerException{DetailMessage: detailMessage, StackTrace: []StackTraceElement{}}
}

func (e NullPointerException) Error() string {
return e.DetailMessage
}

func (e NullPointerException) JavaClassName() string {
return "java.lang.NullPointerException"
}
35 changes: 35 additions & 0 deletions java_exception/object_stream_exception.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright 2016-2019 [email protected]
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package java_exception

type ObjectStreamException struct {
SerialVersionUID int64
DetailMessage string
StackTrace []StackTraceElement
SuppressedExceptions []ObjectStreamException
Cause *ObjectStreamException
}

func NewObjectStreamException(detailMessage string) *ObjectStreamException {
return &ObjectStreamException{DetailMessage: detailMessage, StackTrace: []StackTraceElement{}}
}

func (e ObjectStreamException) Error() string {
return e.DetailMessage
}

func (ObjectStreamException) JavaClassName() string {
return "java.io.ObjectStreamException"
}
37 changes: 37 additions & 0 deletions java_exception/optional_data_exception.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2016-2019 [email protected]
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package java_exception

type OptionalDataException struct {
SerialVersionUID int64
DetailMessage string
StackTrace []StackTraceElement
SuppressedExceptions []OptionalDataException
Cause *OptionalDataException
Eof bool
Length int
}

func NewOptionalDataException(eof bool, length int) *OptionalDataException {
return &OptionalDataException{Eof: eof, Length: length}
}

func (e OptionalDataException) Error() string {
return e.DetailMessage
}

func (OptionalDataException) JavaClassName() string {
return "java.io.OptionalDataException"
}
35 changes: 35 additions & 0 deletions java_exception/stream_corrupted_exception.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright 2016-2019 [email protected]
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package java_exception

type StreamCorruptedException struct {
SerialVersionUID int64
DetailMessage string
StackTrace []StackTraceElement
SuppressedExceptions []StreamCorruptedException
Cause *StreamCorruptedException
}

func NewStreamCorruptedException(detailMessage string) *StreamCorruptedException {
return &StreamCorruptedException{DetailMessage: detailMessage, StackTrace: []StackTraceElement{}}
}

func (e StreamCorruptedException) Error() string {
return e.DetailMessage
}

func (StreamCorruptedException) JavaClassName() string {
return "java.io.StreamCorruptedException"
}
Loading