Skip to content

Commit 58fc7f4

Browse files
committed
fixed codeQL reported issues for Exceptions
1 parent 933ff92 commit 58fc7f4

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ A NetBox plugin for managing service paths and segments in network infrastructur
55
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)
66
[![PyPI version](https://img.shields.io/pypi/v/cesnet-service-path-plugin.svg)](https://pypi.org/project/cesnet-service-path-plugin/)
77
[![Python versions](https://img.shields.io/pypi/pyversions/cesnet-service-path-plugin.svg)](https://pypi.org/project/cesnet-service-path-plugin/)
8-
[![NetBox compatibility](https://img.shields.io/badge/NetBox-4.2%20|%204.3%20|%204.4-blue.svg)](https://github.com/netbox-community/netbox)
8+
[![NetBox compatibility](https://img.shields.io/badge/NetBox-4.4-blue.svg)](https://github.com/netbox-community/netbox)
99

1010
## 📑 Table of Contents
1111

cesnet_service_path_plugin/api/serializers/segment.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
import logging
23
from circuits.api.serializers import CircuitSerializer, ProviderSerializer
34
from dcim.api.serializers import (
45
LocationSerializer,
@@ -14,6 +15,9 @@
1415
from django.core.exceptions import ValidationError as DjangoValidationError
1516

1617

18+
logger = logging.getLogger(__name__)
19+
20+
1721
class SegmentSerializer(NetBoxModelSerializer):
1822
"""Default serializer Segment - now with file upload support"""
1923

@@ -100,9 +104,11 @@ def update(self, instance, validated_data):
100104
instance.save()
101105

102106
except DjangoValidationError as e:
103-
raise serializers.ValidationError(f"Path file error: {str(e)}")
107+
logger.warning(f"Validation Path file error: {str(e)}")
108+
raise serializers.ValidationError(f"Error processing file '{path_file.name}'")
104109
except Exception as e:
105-
raise serializers.ValidationError(f"Error processing file '{path_file.name}': {str(e)}")
110+
logger.error(f"Error processing file '{path_file.name}': {str(e)}")
111+
raise serializers.ValidationError(f"Error processing file '{path_file.name}'")
106112

107113
return instance
108114

@@ -129,11 +135,13 @@ def create(self, validated_data):
129135
except DjangoValidationError as e:
130136
# Clean up created instance if path processing fails
131137
instance.delete()
132-
raise serializers.ValidationError(f"Path file error: {str(e)}")
138+
logger.warning(f"Validation Path file error: {str(e)}")
139+
raise serializers.ValidationError(f"Error processing file '{path_file.name}'")
133140
except Exception as e:
134141
# Clean up created instance if path processing fails
135142
instance.delete()
136-
raise serializers.ValidationError(f"Error processing file '{path_file.name}': {str(e)}")
143+
logger.error(f"Error processing file '{path_file.name}': {str(e)}")
144+
raise serializers.ValidationError(f"Error processing file '{path_file.name}'")
137145

138146
return instance
139147

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "cesnet_service_path_plugin"
7-
version = "5.1.2"
7+
version = "5.1.3"
88
description = "Adds ability to create, edit and view service paths in the CESNET network."
99
authors = [
1010
{name = "Jan Krupa", email = "[email protected]"},

0 commit comments

Comments
 (0)